I know it's possible to change the wrapped type, so that you can have
f :: (a -> m b)
g :: (b -> m c)
f >>= g :: (a -> m c)
but is it possible to change m
? If m
is a MonadError
and is implemented both by an Either ErrorA
and Either ErrorB
, can i somehow chain them? Obviously I can't chain them directly, because what would be the type of Left
? However, I'm in a situation where I end up calling show
in either case, but I haven't found a better solution than
case mightFail1 of
Left e -> show e
Right v -> either show doStuff mightFail2
which fails to properly use the monadic behavior of stopping at the first error without me having to check explicitly.