This is about syntactic sugar in Haskell. A simple Haskell program:
main = do
args <- getArgs
let first = head args
print first
I use binding in the first line (args <- getArgs
) and a pure assignment in the second one (let first = ...
). Is it possible to merge them together into a readable one-liner?
I understand that I can rewrite binding “de-sugared”:
main = do
first <- getArgs >>= ( return . head )
print first
But is there a nicer way, without cluttering the line with (>>=) and return?