haskell / haskell/happy

Add examples and test for type signatures on parametrized productions

Open
#147 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
322
Forks
86
PR merge metrics
No merged PRs in 30d

Description

The current user manual (for version 1.19.12) has this to say about parametrized productions

> A drawback of the current implementation is that it does not support type signatures for the parameterized productions, that depend on the types of the parameters. We plan to implement that in the future---the current workaround is to omit the type signatures for such rules.

This is flat out wrong. Parametrized productions have (for at least several versions) supported type signatures. Examples:

```
many(a) :: { [a] }
: { [] }
| some_rev(a) { reverse $1 }

some_rev(a) :: { [a] }
: a { [$1] }
| some_rev(a) a { $2 : $1 }

then(a, b) :: { (a,b) }
: a b { ($1, $2) }
```

To fix:

* add a regression test case to make sure this is not broken in future versions
* add an example to `examples` for this
* update the user manual

This is somewhat important since there is also bad advice floating about the internet suggesting people use `_` to work around this (see #141 for instance).

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing tests for parametrized productions, the examples directory, and the user manual section quoted in the issue. Confirm the behavior shown in the examples, then add a regression test, an example, and corrected manual text; done means all three requested updates cover type signatures on parametrized productions and the test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
compilers, documentation, testing
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.