Favorite non-famous libraries?


#1

I’ll start – I recently began using path and path-io. Being able to talk about Path Abs Dir instead of [Char] is delightful.


#2

overloaded-records or generic-lens coupled with DuplicateRecordFields take Haskell’s record system from being unremittingly awful to being pretty great. These libraries let you access record fields using overloaded labels, even if there are multiple records with the same field name:

data Foo = Foo { bar :: Int, baz :: Int }
data Foo2 = Foo { bar :: Text }

foo = Foo 37 42
foo2 = Foo2 "Foo"

> foo ^. #bar
37
> foo2 ^. #bar
"Foo"
> foo2 & #bar %~ Text.map capitalize
Foo2 "FOO"

At work, I set up an internal library that does the same thing and it is a massive quality of life improvement for working with business domain code.


#3

The row-types library is a nice one for extensible records that I’ve used in libraries and application code. Not something I’d bring in into a work project without being very careful, but for my personal projects it’s been great.


#4

groom is a tiny one to pretty print Show instances without any additional work, loving it http://hackage.haskell.org/package/groom


#5

Interestingly we can’t all agree on a good path type. Here’s a big discussion on it, if you’re interested: https://github.com/Gabriel439/Haskell-Turtle-Library/issues/54


#6

I really like LazySmallCheck2012, an improved version of LazySmallCheck

QuickCheck finds counterexamples through random generation. SmallCheck
finds them through enumeration. LazySmallCheck generates a single,
unevaluated thunk: if that thunk gets forced, it throws an exception and
LazySmallCheck tries again with more specific values (e.g. if the thunk
is _ :: [Bool], it will try again with [] :: [Bool] and
(_:_) :: [Bool]). This:

  • Generates minimal counter-examples (like SmallCheck)
  • Only tests those ‘branches’ of the input space which affect the
    property (i.e. those thunks which get forced)
  • Can tell us when a subexpression was irrelevant (its thunk wasn’t
    forced), e.g. checking fst :: (Bool, Bool) -> Bool will find the
    counterexample (False, _) (unlike SmallCheck’s (False, False))
  • Can prove certain properties hold for all inputs (when no more thunks
    get forced)

The original LazySmallCheck is pretty limited in what it can handle,
whilst the “2012” rewrite can handle much more (e.g. functions).

It’s not on Hackage and seems unmaintained, which is a bit of a shame
( https://github.com/UoYCS-plasma/LazySmallCheck2012/issues/11 )

Nevertheless I’ve been happily using it for years :slight_smile:


#7

@warbo have you looked at leancheck? I think it’s the same idea, but on Hackage


#8

Ollie Charles via Haskell Community discourse@haskell.org writes:

@warbo have you looked at leancheck? I think it’s the same idea, but on Hackage

I’ve seen leancheck (but not used it); from what I know it’s roughly the
same idea as SmallCheck rather than LazySmallCheck, i.e. it enumerates
complete values rather than ‘unfolding’ a partial value.

TBH I default to using QuickCheck for most things; but I wouldn’t call
QuickCheck a “non-famous library” :slight_smile:


#9

I feel silly when looking at code that uses complicated mappers where only a bit static escaping would suffice. SQL is still a best DSL for writing structured queries. With some help on a composition side it continues to shine no matter what.


#10

I like tree-diff package:

It’s not that popular actually. But looks like a lot of work was put into it. I recently used in Haskell packages scaffolding tool called Summoner to compare directory structure including file contents, and it worked like a charm out of the box!


#11

Not sure if it counts as “non-famous” but I recently used dlist - it’s quite useful.


#12

Not famous now, but will surely be in the future: http://hackage.haskell.org/package/generic-data

Especially with 8.6 & derivingVia it is a charm.