[Haskell-cafe] one-way monads
Dan Doel
dan.doel at gmail.com
Wed May 21 00:02:05 EDT 2008
On Tuesday 20 May 2008, ajb at spamcop.net wrote:
> Actually, it's true less than 50% of the time. In particular, it's
> not true of any monad transformer.
Sure it is. Any particular transformer t typically comes with some particular
way of writing a function of type t m a -> m a (you may have to throw away
some t-related stuff, of course).
Since a specific transformed monad is built from a specific monad, and a
specific transformer, and specific transformers are likely to have a function
of type t m a -> m a, and specific monads are likely to have functions of
type m a -> a, you can compose them to get a function of type t m a -> a for
the specific monad t m. And so on for transformed-transformed monads. :)
That only fails if either of the specific pieces fails to have the right
function, which happens well under 50% of the time, I think (IO and STM are
the ones that immediately occur to me (barring a certain evil function),
although you could make a case for ST by technicality; no failing
transformers come to mind (except CCT if we're counting ST), but I haven't
wracked my brain very hard).
-- Dan
More information about the Haskell-Cafe
mailing list