[Haskell-cafe] Monad Syntax

caseyh at istar.ca caseyh at istar.ca
Mon Dec 13 22:06:41 CET 2010


A Neighborhood of Infinity

Monday, August 07, 2006
You Could Have Invented Monads! (And Maybe You Already Have.)


The following part:

     let x = 7
     y <- Writer (x+1,"inc\n")
     z <- Writer (2*y,"double\n")
     Writer (z-1,"dec\n")

The notation is very suggestive. When we write y <- ... it's as if we  
can pretend that the expression on the right hand side is just x+1 and  
that the side-effect just looks after itself.

Why pretend?
Couldn't the syntax be:

     let x = 7
     y <- x+1, Writer ("inc\n")
     z <- 2*y, Writer ("double\n")
     z-1, Writer ("dec\n")

Or some other delimiter than the comma?

I'm thinking this syntax might be easier to understand. :)

More information about the Haskell-Cafe mailing list