Skip to content

Increase precedence of lexps (if-then-else, case-of, do, lambda and let-in)

Intro

For readability, the intro is now available here.

How it works

  • Implicit parenthesis will be put around all lexps, according to the following rules:
  1. Parenthesis will be opened at the start of the lexp.
  2. Parenthesis will be closed at the end of the lexp. The end of the lexp is determined by
  3. The curly brackets around the lexp (If possible), or;
  4. The indentation of the lexp

Basically, these are the rules Haskell already uses.

As for the Context-Free Syntax found at https://www.haskell.org/onlinereport/haskell2010/haskellch10.html#x17-17800010.3|layout, lexp would have to be moved up, dropped out of infixexp, and added into exp (As well as a few other places in aexp and guard)

Motivation

As for my personal motivation, I think that, with all the other syntactic extensions already implemented, this feature is definitly missing.

As Richard Eisenberg already pointed out (See this comment); combining lexp with aexp would make the Haskell syntax more consistent.

bgamari listed above argument and quite a few other pros and cons here.

A few arguments not listed there:

  • If the Haskell community ever decides to implement this feature in the main language, we will already be prepared.
  • Similairly, if this feature ever gives problems or adds new interesting possibilities to the language, we will be prepared.
  • Yet another syntactical extension means yet another thing to look out for;
  • However, this also means people will become more aware of LANGUAGE pragmas.

Naming

Here follow a few suggestions for the name of this extension:

  • InlineStatements
  • InfixStatements
  • ParenthesizedStatements
  • IncreasedStatementPrecedence
  • StatementsWithoutParenthesis

Here are some more, taken from over here.

  • ArgumentBlock
  • ArgumentDo

Examples

Examples can now be found here.

Resources

[1] Cheesy intro: http://pastebin.com/8Fsh7pAE

[2] Original examples: http://pastebin.com/6kLQvKs9

[3] Pros and Cons: https://ghc.haskell.org/trac/ghc/ticket/10843#comment:12

[4] ArgumentBlock proposal: https://mail.haskell.org/pipermail/haskell-cafe/2015-September/121217.html

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