[Haskell-cafe] do
Tim Newsham
newsham at lava.net
Mon Dec 3 13:25:24 EST 2007
> Probably one should understand how to use monads before worrying about
> the do-notation. Here are some references:
I don't totally agree. You can teach monads to beginners just fine
using the do-notation. Unsuprisingly its very much like teaching
monads using bind. You describe a two line do-block as the basic
building block for combining two actions into a single action:
do {
result1 <- act1
expr involving result1 building an act
}
show that you can nest them (expr can be another do block)
do {
result1 <- act1
do {
result2 <- act2
expr involving result1 and result2 building an act
}
}
and how the do-notation doesn't require you to start a new do-block
for nesting of do's and let's
do {
result1 <- act1
let val1 <- expr resulting in a pure value
result2 <- act2
expr involving result1 and result2 building an act
}
Then you can describe pattern matching and fail...
I've had debates about what should be taught, and obviously not
everyone agrees, but at the least, its possible and reasonable
and understandable to teach do-notation first.
> Denis
Tim Newsham
http://www.thenewsh.com/~newsham/
More information about the Haskell-Cafe
mailing list