[Haskell-cafe] Re: philosophy of Haskell

Ertugrul Soeylemez es at ertes.de
Mon Aug 9 09:38:42 EDT 2010


jerzy.karczmarczuk at info.unicaen.fr wrote:

> Alberto G. Corona  writes:
>
> > (...) Desugarize the "do" notation, after that, desugarize the >>=
> > and >> operators down to the function call notation and suddenly
> > everithing lost its magic because it becomes clear that a haskell
> > monad is a sugarization of plain functional tricks.
>
> Yep.
>
> But, BTW, could you tell me what was the result of the final
> desugarization and the BASIC sense of the IO monad for you?

Example:

  do x <- getLine
     print (x+1)
     print (x+2)

There are various models.  One (the state monad model) of them would
desugar this to:

  \world0 ->
  let (x, world1) = getLine world0
      world2 = print (x+1) world1
      world3 = print (x+2) world2
  in world3

Another one (the EDSL model, which I personally prefer) would desugar it
to something as simple as this:

  GetLine `BindIO` \x ->
  Print (x+1) `BindIO`
  const (Print (x+2))

I wonder if there are more models for IO.


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/




More information about the Haskell-Cafe mailing list