[Haskell-cafe] extending Do notation
silvio
silvio.frischi at gmail.com
Tue May 20 14:27:05 UTC 2014
> 2) you can't use >>= in an if condition
look at the first if in base package that i is not a comment
ok <- getProcessTimes ...
if toBool ok
then do
since getProcess has many actument's this is good code, but imagine it
was a short IO function
if toBool { getProcessTimes ... }
then do
looks much better you can't pipe the result of getProcessTimes into the
if conditional. Unless you use a lambda of course.
> 3) or imagine you want to fill it in some 3-tuple or a record type.
>
> What does this mean?
someIOFunction ({getProcessTimes ...}, foo, bar)
someIOFunction (foo { bar = {getProcessTimes ...}})
>
>
> 4) res <- fmap pureFunction ioFunction === let res = pureFunction {
> ioFunction}
>
>
> From a distance, let and monadic bind are just different forms of name
> binding.
>
> But haskell's let has an effectlessness that makes it declaratively
> different from its cousin in, say, ocaml.
>
> This is no small change you're proposing.
You might have misunderstood. The 'let' in the do notation is already
different from the normal 'let' in that it doesn't have an 'in' for
example. {} should of course only work inside a do block.
silvio
More information about the Haskell-Cafe
mailing list