Skip to content

Allow do blocks without dollar signs as arguments

I would like the following to be valid Haskell code:

main = when True do
  putStrLn "Hello!"

Instead of requiring a dollar sign before the "do". This would parse as

main = when True (do
  putStrLn "Hello!")

Similarly, allow lambdas in the same way

main = forM values \value ->
  print value

parses as

main = forM values (\value ->
  print value)

One possible question: does this also do the same thing for LambdaCase? I think that since people expect lambda case to just be a simple desugaring it should also work, so then

main = forM values \case
    Just x -> print x
    Nothing -> print y

parses as

main = forM values (\case
    Just x -> print x
    Nothing -> print y)

Wiki page: ArgumentDo

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information