[Haskell-cafe] GHC Extension Proposal: ArgumentBlock

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sun Sep 6 12:53:04 UTC 2015


On Sat, Sep 05, 2015 at 03:55:37PM -0700, Andrew Gibiansky wrote:
> I'd like to propose a GHC extension called (for now) `ArgumentBody`.
> `ArgumentBody` is a simple syntax extension, than, when enabled, permits
> the following code:
> 
> main = when True do
>   putStrLn "Hello!"
> 
> 
> main = forM values \value ->
>   print value
> 
> 
> main = forM values \case
>     Just x -> print x
>     Nothing -> print y

By the way, you can already do

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


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


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

which gets you a lot of the way, and is arguably even clearer.  This is as
style that has been promoted by Chris Done.

Tom


More information about the Haskell-Cafe mailing list