Haskell is easy - a list of recommended Haskell libraries

To make it more true that Haskell is easy, here's a list of curated libraries. In the personality descriptions matching you to a library, be honest with yourself about where you're at and what your needs are.

This isn't listing for listing's sake. I've either used it or someone whose taste and experience I really trust has used it. If you list everything, the list is useless to somebody that can't sniff test the API quickly.

Disclaimer

I wrote Haskell book. I mention where things in this list (which is very opinionated) are covered in the book. I don't care if you buy our book.

Getting Haskell installed

Use Stack!

Basic data structures

Benchmarking

  • criterion is a library for benchmarking. Criterion uses statistics to help prevent you lying to yourself.

Binary serialization/deserialization

Stuff that is somewhat opinionated about how your data looks over the wire

I wanna write my own!

Command-line argument parsing

  • optparse-applicative is a command-line arguments parser library - easy flag/switch definitions and automatically creates useful help pages

Concurrency / synchronization

  • Much of the time you'll probably just use database transactions to coordinate updates to data, but if you need something in-memory start with something composable like STM

  • See the note on concurrency to learn more.

CSV

Bytes

Elasticsearch

  • Bloodhound note you'll have to use Aeson version 0.10 or newer.

File I/O

Text

Bytes

  • ByteString's core modules have the basic IO operations you'd need included.

HTTP clients

I just got here and don't know what I'm doing

Know what I'm doing and I'd like more fine-grained control over resources, such as streaming

Please see the note on streaming before using any streaming libraries.

JSON

lenses

  • lens you'll have to cargo cult early on and it's best if you're not a beginner, but there's nothing better if it's something you're going to use instead of framing the source code and mounting it over your fireplace.

Logging

Network I/O

Network.Socket.Bytestring in the network library.

NLP

  • chatter a collection of simple Natural Language Processing algorithms.

Parsing

Regular expressions

SQL

I'm new and just want to throw a query over the wire!

PostgreSQL
MySQL
SQlite

I'm not totally new to Haskell and willing to invest in something more type-safe!

Statistics

Streaming

Take the note on streaming under advisement. Don;t

Testing

Unit/spec testing

Property testing

Text / strings

  • Use text if you're going to have a non-trivial amount of textual data in memory, but don't freak out about using the String type for small stuff. Sometimes String is faster anyway because of GHC's optimizations for lists.

Time

  • Funnily enough, time is the foundational library.

I need something faster than time or I use a lot of timestamps!

Utility libraries and conveniences

  • classy-prelude can save you some grief, particularly around mixing IO, String, ByteString, and Text. Best used with a project template that disables Prelude by default and gets an import module in place for you.

  • composition-extra mostly for this bad boy. Double-fmap! I am easily amused.

Web Frameworks

I just need to make a tiny API or I just started

I'm going to make a web application I have to maintain and I'm comfortable with a more opinionated framework

  • Yesod also better for APIs if you can handle something more advanced than Scotty.
    • Yesod book
    • Carnival open source comments app.
    • Snowdrift.coop a non-profit, cooperative platform for funding public goods, specifically Free/Libre/Open (FLO) works.

XML

Note on concurrency

For learning how to write parallel and concurrent programs in Haskell, Marlow's book is peerless.

Note on streaming

Pipes is generally easier to use than Conduit and can be quite pleasant. However, if you're new to Haskell you should avoid using streaming libraries unless necessary to control memory usage. Mostly because you'll spin your wheels on which operator to use and the type errors won't help much. YMMV.