[Haskell-cafe] Re: do

Jonathan Cast jonathanccast at fastmail.fm
Mon Dec 3 21:02:26 EST 2007

On 3 Dec 2007, at 4:19 PM, Dan Piponi wrote:

> On Dec 3, 2007 3:54 PM, Ben Franksen <ben.franksen at online.de> wrote:
>> I don't buy this. As has been noted by others before, IO is a very  
>> special
>> case, in that it can't be defined in Haskell itself, and there is no
>> evaluation function runIO :: IO a -> a.
> I'm not sure what a function of type m a -> a has to do with the
> concept of a monad.

Nothing.  But there are plenty of legal, safe functions of type m a - 
 > a for almost all monads m.  Except those based on IO.

So leading off with IO can lead to the impression that (a) monads are  
impossible to break out of / can't be used in purely functional code  
or (b) the main point of monads is to let you write imperative code  
in Haskell.  The main point of monads is that they're so common in  
Haskell we'd be crazy not to call them /something/, just so we have  
something to say when we realize, "hey, this is another of those  
thingies with a return and a bind!"  IO is quite atypical as far as  
the class of monads we use every day in Haskell goes; the absence of  
any useful, safe, pure function of type IO a -> a is a (small)  
instance of that atypicality.

IMHO, teaching IO first and then saying, monads are things that are  
like IO, is very counter-productive.  In particular, I think it's why  
so few people understand the list monad (which is of course one of  
the pardigmatic examples).

Just my 2c, of course.


More information about the Haskell-Cafe mailing list