Skip to content

Commit

Permalink
Add examples of comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
facundominguez committed Jan 8, 2019
1 parent 3312412 commit de6f3b0
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,55 @@ data A

TODO: GADTs, record syntax, type families

### Comments

```Haskell
{- When a comment is not preceded with elements on the same line,
they are indented as the elements in the enclosing AST node or
braces/parenthesis/brackets.
If it is between AST nodes, it is indented as the following
node.
If the end-of-file follows, then indent to column 0.
-}

f = g {- When there are preceding elements, keep single-line comments in the same line. -}

h = g
{- Multi-line comments can't be kept on the same line as @h = g@.
Otherwise, changing h or g would change the indentation of all
the comment lines.
-}

data R = R
{- This comment always follows the R constructor -}
{ f1 :: T1
{- A comment not preceded by other elements -}
{- Another comment -}
, f2 :: T2
, f3 :: T3
}
```

```Haskell
{- a comment line -}
f = h
where
h = g
-- indented the same as g
g = False
```

This example
```Haskell
data R = R {- This comment always follows the R constructor -}
{ f1 :: T1, {- An inner comment -} {- Another inner comment -} f2 :: T2, f3 :: T3}
```
is reformatted to
```Haskell
data R = R
{- This comment always follows the R constructor -}
{ f1 :: T1 {- An inner comment -} {- Another inner comment -}
, f2 :: T2
, f3 :: T3
}
```

0 comments on commit de6f3b0

Please sign in to comment.