3 ms·
In a sufficiently expressive language, do-notation isn't that important. Consider the following pieces of (equivelent haskell) f1 = do fd <- open
by gizmo686 4y ago
In a sufficiently expressive language, do-notation isn't that important. Consider the following pieces of (equivelent haskell)
f1 = do
fd <- openFile "/file/path"
contents <- readFile fd
let result = process contents
closeFile fd
return result
f2 = openFile "/file/path" >>= \fd ->
readFile_ fd >>= \contents ->
let result = process contents in
closeFile fd >>
return result
Sure, the code for f1 is easier to read, but not by that much. You have a bit more noise in each line with the explicit operators being added. The only big readability difference I see is that you have moved to bound variable to the end of lines instead of the start. I've never actually worked in a codebase that regularly did this, but I suspect you would get used to it frequently. The inconsitency with let statements putting the bound variable on the left would be a readability drawback; but I can easily imagine a language that allows for putting the bound variable on the right hand side of an assignment, such as (not Haskell):
let process contents -> result in