This is from Expert F# 2.0 page 231. Apparently the following block of code
attempt { let! n1 = failIfBig inp1
let! n2 = failIfBig inp2
let sum = n1 + n2
return sum };;
de-sugars to this:
attempt.Bind( failIfBig inp1,(fun n1 ->
attempt.Bind(failIfBig inp2,(fun n2 ->
attempt.Return sum)))))
but where is sum computed in the de-sugared variant? I expected something more like this:
attempt.Bind( failIfBig inp1,(fun n1 ->
attempt.Bind(failIfBig inp2,(fun n2 -> let sum = n1 + n2 in
attempt.Return sum)))))
Yes it’s an error in the book and it should be de-sugared as below: