Free ListT transformer

I created a new ListT library:

It has a lawful list monad transformer based on free monads and an applicative transformer isomorphic to the “old” ListT.


Is there any advantage of defining ListT like this over the usual “fixed” definition, i.e.:

data ListF a f = NilF | ConsF a f
newtype ListT m a = ListT (m (ListF a (ListT m a))) 

I guess you get most of the instances for free from the free monad instance, but now you have to flatten the tree into a list all the time.

Edit: nevermind I see the description on hackage now.

Edit2: The readme did not clear up all questions. My main question now is why you are calling this a list transformer. It is not a list transformer, i.e. your ListT Identity a is not isomorphic to [a]. Your ListT is a rose tree tranformer. Or am I making a mistake?

That’s not to say I don’t think this is useful and perhaps more people will try it out if you call it ListT, but I think RoseT (or TreeT like hedgehog has) would be a better name to avoid confusion.


I guess you are right, it should really be called TreeT or RoseT! I think my main point is that the Applicative transformer still exists and is useful.

And my second point is that you can use TreeT in many situations where you’d otherwise use ListT.