2 ms·
It's for being able to write functions that are generic in the context they operate in. You absolutely would want to do this in Erlang, or in SML if the type sy
by lmm 11y ago
It's for being able to write functions that are generic in the context they operate in. You absolutely would want to do this in Erlang, or in SML if the type system supported it.
E.g. I can use Future for managing async-ness. I can use a system a bit like http://typelevel.org/blog/2013/10/18/treelog.html http://typelevel.org/blog/2013/10/18/treelog.html for weaving statistics collection through my computation. I use Free to express database operations that need to happen in a transaction. I can use Either to handle operations that might fail.
I can write a method that builds a report from a bunch of rows that works with any of these four contexts, because all of them form monads.