Libraries
This page contains a list of libraries that could be really useful for your project.
Megaparsec
Megaparsec is a parser combinator library, and it is the one that we have met in the lectures. However, megaparsec is not always the best choice. If you are parsing human made text, like a config file or a program, then this is a fantastic library. It has build in file and line tracking, as well as great error messages to show the author of the content. But if you are parsing TCP protocols (and similar) then attoparsec is a much better choice.
Gloss
gloss is a simple library for building games and simulations. Most importantly, it is really fun to use.
Brick
Brick is a TUI library. If you have installed GHC with ghcup, then type ghcup tui and you will see what a terminal user interface is. It even has mouse support! Also, it has an easy to read user guide to supplement what you get on hackage. (Note, the guide isn't rendering on GitHub properly, but you can still read it)
Network
Network is a bit of a tricky package. It provides the exact same API as the POSIX socket library (the one you find in C on linux). So if you have done socket programming before, you should feel right at home, but if you have not, it might be easier to use network-simple.
Discord-Haskell
Discord-Haskell is a library for making discord bots.
Calamity
Calamity is a potentially much nicer library than discord-haskell, but looks as if it requires more advanced haskell features to use. Don't necessarily let this deter you. It looks like in this case, the language extensions are used simply to make the library easier to use and the code more readable.
Attoparsec
attoparsec is a lightning fast parsing combinator library designed for use in network protocols (and similar). As a result, the error messages that it generates are terrible. But it makes up for this by being simpler to use than megaparsec and has the ability to stop and resume parsing. This is great because you often don't know how many bytes you need from a socket and can easily ask for too few.
Optparse-Applicative
Optparse-Applicative is a super simple library for parsing command line arguments and generating help. Really elegant.
Servant
Servant is a library for making REST APIs. What makes it stand out from the crowd is its flexibility and how little boilerplate you have to write. Notable features include:
Typed end points. You don't need to parse strings
Loads of plugins (e.g. servant-lucid for serving HTML instead of JSON)
Automatic client generation for haskell, javascript
I would advise that you check out the documentation. It's pretty comprehensive. Also talk with James about the required language extensions. You don't have to understand the theory, to understand how to use this library or why it's amazing!
Lucid
Lucid is a really fun monad for generating HTML. It is easier to work with than... HTML
Aeson
Aeson is a library for the automatic serialisation and de-serialisation of JSON.
Diagrams
Disagrams is a haskell classic! It's a lovely library for building diagrams through composition. It has a tutorial here.
Selda
Selda is a really nice DSL for interfacing with SQLite and PostgreSQL. It has a nice tutorial as well! But do note that the version on hackage has not been updated in a while. If this causes problems, there is an easy fix to try. Just ask James!
General Library Advice
Just some tips:
Strings
In haskell, we don't often use String. It just isn't efficient for 99% of purposes.
We use text for UTF-8 strings
We use bytestring for raw byte streams
Both these packages have strict and lazy versions with the same name!
You will want to look at qualified importing when using these libraries
Adding
{-# Language OverloadedStrings #-}will allow you to write a string in your code, and have haskell interpret it as aTextorBytestringwithout an explicit conversion
Language Extensions
Some Libraries require language extensions to use properly and the code may look unfamiliar. Don't panic! In haskell libraries developers will often travel to the absolute edges of the haskell type system, simply to make a library that really safe, clean and easy to use... on the condition that you know how to use the required syntax. You can always ask James in the group sessions what a language extension does, or at least how to use it.