[Haskell-cafe] Re: what is inverse of mzero and return?

Keean Schupke k.schupke at imperial.ac.uk
Mon Jan 24 05:32:19 EST 2005

Ashley Yakeley wrote:

>I don't believe this represents a good understanding of IO actions as 
>Haskell values. For instance, 'return ()' and 'putStrLn "Hello"' are the 
>same type, but are clearly different actions and so are usually 
>considered to be different values. That the latter prints out text might 
>be better considered not so much a "side effect" as the actual action 
>You've introduced the concept of "the value of" an IO action, apparently 
>as something separated from "side effects". I don't believe you can 
>properly define this. For instance, what is the "value" of getChar such 
>that it doesn't involve "side effects"?
Right, but we are dealing with the type system here. Remember Haskell
monoids are functors on types, not on values ... (ie the base objects the
'category theory' is applied to are the types not the values)...

Therefore we only consider the types when considering Monads.

As such if you wished to consider the examples you gave distinct, the
type system would need to distinguish side effects... this can be
done with a linear-aliasing type system, but not Haskell's as far as I 
Maybe you could write such types:

    {putStrLn "Hello"; mzero} :: IO (PutStrLn "Hello" => ()) ???

But if we look at the type of the Functor:

    fmap :: (a -> b) -> m a -> m b

Where is the IO action?


More information about the Haskell-Cafe mailing list