by zimpenfish · 7y ago · 0 comments
I'm also assuming that `f first second` will return (an error monad?) if either of `first` or `second` are (an error monad?) - is that right?
return is a bit of a misnomer in Haskell -- it really means "wrap this value in the monad supplied by the context." So as other commenters have mentioned, f(...) cannot fail. Non-monadic Haskell functions never use return.
If f could fail and you indeed wanted to propagate its error if it did fail, you could write the code as
do first <- computeFirst
second <- computeSecond
f first second