The use of type-aligned
in freer
extensible effects is aimed at minimizing the cost of "appends", i.e. monadic binds, when constructing (accumulating) a large pure free-monadic expression. This is avoided in a different way in the streaming libraries, which are also implemented as free monads. Something like freer
will always be more expensive than the elementary transformers in transformers
since it is a recursive type. The deep distinction is between recursive types like Free XYZ
and stuff like StateT Int
(and then again, under the latter heading, between recursive and non-recursive programs.). Because of the chance historical fact that no recursive transformer types are represented in transformers
(I ignore the so-called ListT
) it is possible to write infinitely many blog posts proving that transformers
is better than free monads by e.g. comparing StateT
with Free StateAction
, which is permanently hopeless. But if tranformers
had a real ListT
we could e.g. compare ListT (State Int) Char
with Free (Sum (Yield Char) (StateAction Int)) ()
or whatever, and the differences would not be particularly striking.