[<<][haskell][>>][..]

Sat Sep 1 10:50:02 EDT 2018

## Monad transformers

So here's what I want to know. Composing the standard monad
transformers is easy as long as you need only one of each. How to use
multiple instances? This seems like a reasonable request, but there
is no simple way to do this.
The idea I had is to create new transformers, and compose monads out
of those.
So, is the solution to use 'lift' instead?
http://blog.ezyang.com/2013/09/if-youre-using-lift-youre-doing-it-wrong-probably/
Interesting points, but what I'm looking for is some practical advice.
I’ve settled on a development style that uses monad transformers
to derive problem-specific monads, but wraps them in a newtype to
hide their generic structure. Each newtype’d monad is accompanied
by meaningfully named wrappers around ‘ask’, ‘get’, ‘set’, etc.,
lifted as necessary. Only these wrappers deal with the monad
stack. This way, monad transformers remove the work of writing
boilerplate monad implementations, but they don’t eliminate the
need to write an interface, and I’m fine with that.
E.g. when there are multiple state components, an interface needs to
be written anyway. So maybe best to do it in terms of 'lift', as
opposed to packing/unpacking tuples.

[Reply][About]

[<<][haskell][>>][..]