[Haskell-cafe] monads with take-out options

Jules Bean jules at jellybean.co.uk
Wed Nov 26 14:09:28 EST 2008

Greg Meredith wrote:
> Haskellians,
> Some monads come with take-out options, e.g.
>     * List
>     * Set
> In the sense that if unit : A -> List A is given by unit a = [a], then 
> taking the head of a list can be used to retrieve values from inside the 
> monad.
> Some monads do not come with take-out options, IO being a notorious example.
> Some monads, like Maybe, sit on the fence about take-out. They'll 
> provide it when it's available.

To amplify other people's comments:

List A is just as on the fence as Maybe. "[]" plays the role of "Nothing".

Some monads require that you put something in, before you take anything 
out [r -> a, s -> (a,s), known to their friends as reader and state]

Error is similar to Maybe, but with a more informative Nothing.

Most monads provide some kind of

runM :: ## -> m a -> ## a

where the ## are meta-syntax, indicating that you might need to pass 
something in, and you might get something slightly 'funny' out. 
Something based upon 'a' but not entirely 'a'.

The taxonomy of monads is pretty much expressed in the types of these 
'run' functions, I think.


More information about the Haskell-Cafe mailing list