[Haskell-cafe] One-way and two-way monads.

Keith Wansbrough Keith.Wansbrough at cl.cam.ac.uk
Mon Oct 18 10:34:01 EDT 2004

> Dear All,
> List and IO are both monads when appropriate operations are defined. 
> The IO monad, which is a one-way monad, does not have a function of
> type IO a -> a, in general, except an unsafe function 
> "unsafePerformIO :: IO a -> a". A two-way monad, such as List, has such 
> a function "head :: [a] -> a".

But "head" sometimes fails.  So List isn't a two-way monad either.
(if you accept partial functions, then *all* monads are two-way, since

  otherway :: m a -> a
  otherway x = error "foo"

has the desired type).

--KW 8-)

More information about the Haskell-Cafe mailing list