haskellfoundation / haskellfoundation/haskell-2010-revised-report

Allow arbitrary levels of parentesization of types

Open
#54 1 comment 0 reactions 0 assignees View on GitHub
feature: language report
Dominant language
Typst
Stars
20
Forks
5
Avg merge
4d 18h
Merged PRs (30d)
6

Description

In GHC without any extensions, the syntax of types and contexts is relaxed compared to Haskell 2010 report in that parentheses are allowed. This discrepancy is not documented in the GHC Users Guide.

The report states, for example, that a class constraint may contain at most one pair of parentheses to wrap the type and its parameters following the class name:

```
f :: Show (t Int) => t Int -> String
f = show
```

GHC will however take the following as equivalent:

```
f :: (((Show) (((t) (Int))))) => t Int -> String
f = show
```

This declaration is also perfectly legal in GHC even though the parens make it syntactically incorrect according to the Haskell Report:

```
type (Syn t) = ()
```

It would be relatively easy to relax the report grammar to allow arbitrary parenthesization of types, certainly easier than modifying GHC to restore its compliance with the report.

Contributor guide

Open the contributing guide

Research direction

Start with the Haskell 2010 report grammar sections covering types, contexts, class constraints, and type declarations, then compare them with the parenthesized examples in this issue. Update the grammar so the documented syntax matches GHC's behavior, and verify that the examples are accepted by the revised report.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
compilers, documentation
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.