Is this the correct desugaring calculation workflow?

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 sum, calculated in the de-sagar version? I was expecting something more:

attempt.Bind( failIfBig inp1,(fun n1 ->
attempt.Bind(failIfBig inp2,(fun n2 -> let sum = n1 +  n2 in
attempt.Return sum)))))
+3
source share
1 answer

Yes, this is a mistake in the book, and it should be undone, as shown below:

attempt.Bind( failIfBig inp1,(fun n1 ->
attempt.Bind(failIfBig inp2,(fun n2 -> let sum = n1 +  n2 in
attempt.Return sum)))))
+2
source

All Articles