#3097: Parser doesn't support doc comments on type aliases
---------------------------------+------------------------------------------
Reporter: waern | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.11
Severity: major | Resolution:
Keywords: Haddock | Difficulty: Unknown
Testcase: | Os: Unknown/Multiple
Architecture: Unknown/Multiple |
---------------------------------+------------------------------------------
Comment (by waern):
Replying to [comment:1 simonpj]:
> David,
>
> This looks accidental to me. In general, our story is: if it makes the
parser simpler, then it's fine to make the parser more generous (ie
willing to parse more stuff), and reject illegal programs later.
Thanks! It is very useful to know this principle.
> So maybe you should replace ''every'' use of ctype with ctypedoc (or
rather rename the latter to be the former)? That would go further than
you need, and would allow 'docs' to be parsed in more places. But if it
doesn't give rise to ambiguities, it'd be fine by me.
I originally tried to replace each `ctype` with `ctypedoc` but it gave
rise to an ambiguity when parsing record fields. Comments on fields
clashes with comments in field type signatures. So we really need two
different productions.
So what I want to do now is to just change type synonyms to use
`ctypedoc`.
To do that, I'd like to extend `ctypedoc` so it allows everything allowed
by `ctype`. That seems to work fine.
But remember that `ctypedoc` supports syntax not supported by `ctype`. It
allows foralls/contexts after a contex implication (=>). So this is the
remaining problem. By changing type synonyms to use `ctypedoc` we allow
more things in type synonyms than we did before.
Here is an example:
{{{
{-# LANGUAGE Rank2Types #-}
import Control.Arrow (Arrow(..))
(>>>) :: forall arr. Arrow arr => forall a b c. arr a b -> arr b c -> arr
a c
(>>>) = undefined
type Foo = forall arr. Arrow arr => forall a b c. arr a b -> arr b c ->
arr a c
}}}
The type signature for (>>>) is accepted since it uses `ctypedoc` which
allows this syntax. But we have not accepted the declaration `Foo` before.
With `ctypedoc` in type synonyms, it will now be accepted. Is that OK?
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3097#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs