Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I mostly agree with what you are getting at here. However occasionally it is useful to abstract over all Functor or all Monads, etc.

For example, when using the Van Laarhoven free monad[0] implementation, I'll quantify over all monads. While, there is a simple data type definition for free monads[1], it suffers from a well-known issue that the bind operation has quadratic complexity. The Van Laarhoven free monad circumvents this problem (at least in the common case where you are not trying to "execute" the intermediate monadic constructions). There are also continuation-based approaches for free monad implementations as well.

The benefits of free monad are the typical ones described in "Data types à la carte" where you can, for example, instantiate your free monad in the IO monad for production, but use a pure monad instance for (parts of) your test harness.

(Generic implementations of free monads and their operations is another example of quantifying over all Functors, but I'm assuming for the sake of argument that you'd prefer to repeat that boilerplate over and over again for all your specific free monad instances.)

[0] http://r6.ca/blog/20140210T181244Z.html

[1] https://hackage.haskell.org/package/free-5.1.7/docs/Control-...

[2] http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesALaCa...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: