
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". My rough question is: Is there any intersting theory on the relationship between one-way monads and two-way monads? For example, a restriction on the IO monad would offer a *safe* "unsafePerformIO", and so the IO monad would become a two-way monad. Does this question make sense at all? Thanks in advance. Kwanghoon Choi

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-)

Hi Keith Wansbrough wrote:
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
[..] ...partiality is itself a monadic effect? Cheers Conor -- http://www.cs.rhul.ac.uk/~conor
participants (3)
-
Conor McBride
-
Keith Wansbrough
-
Kwanghoon Choi