Good Haskell Libraries

25 points by abhin4v a day ago on lobsters | 10 comments

jmtd | a day ago

I've used almost none of these! I've had exposure to regex-tdfa (via hledger) and I found it semi-awkward, although that could be the way it's embedded in hledger; I also adopted the mentioned algebraic-graphs which I would generally recommend although for the thing I used it for ultimately I decided I shouldn't have.

I'll throw out a recommendation for HTF (haskell testing framework) which for some reason seems very out-of-favour. It wraps HUnit and QuickCheck, but lets you write tests or properties in one-liners right next to the code they are testing, without any boilerplate. No need to build weird heirarchies of test trees; the test function names are their description. I find that reduced friction is great for encouraging me to actually write tests:

def someFunction :: SomeIn -> SomeOut
someFunction = ...

test_someFunction_fooble = ...
prop_someFunction_fnargh = ...

Sanity | a day ago

that seems very ergonomic :) seems to use a GHC plugin, is there any special setup needed apart from the pragma or do you not really notice it? Does it cause any issues with the language server?

vaibhavsagar | 13 hours ago

Quick recommendation for retry, which I've used at two different workplaces to great effect.

jackdk | 11 hours ago

Thoughts on retry vs. stamina? I should probably add one of them to the list.

Sanity | a day ago

Nice list, though for things like semialign I'd probably just write my own function rather than add a dep.

If we're recommending, here are some that I enjoy using:

  • typed-process – type-safe shelling out
  • postgresql-simple – simple db workhorse
  • attoparsec – fast, readable parser combinators
  • tagsoup – easy scraping
  • async and stm – do stuff concurrently and safely
  • stm-containers – necessary when changing maps in stm
  • vector-hashtables – much faster than unordered-containers
  • fast-logger – simple logging workhorse
  • optparse-applicatives – easily, declaratively define cli arg handling
  • wai – simple http serving
  • alfred-margaret – fast search for multiple strings in big texts
  • dataframe – for exploring data (though I have yet to use in production)
  • doctest – for inline tests
  • QuickCheck – the OG property testing framework. I know people say hedgehog is better, but there are more docs and integrations for QC, so it feels more comfortable

refi64 | a day ago

async and stm – do stuff concurrently and safely

ki is another great one in this space too, a bit more generalized than async is.

Sanity | a day ago

What are the advantages over async? (I'm often a bit hesitant of depending on stuff that's not the most standard/popular, especially for something so bug-prone as concurrency.)

robgssp | 20 hours ago

It gives you first-class thread scopes, so at any point within a scope you can spawn off new threads against that scope and they'll all get cleaned up when the scope returns. It's handy for things like spawning off a thread per network request, where individual thread lifetimes don't nest cleanly so concurrently/withAsync can't really be used.

jkachmar | 23 hours ago

  • attoparsec – fast, readable parser combinators

check out flatparse! it’s an even faster & more efficient parser combinator library with emphasis on better compile times and fewer allocations.

Sanity | 5 hours ago

Thanks, very interesting, I will have to give it a go :-)