Opened 4 years ago

Closed 13 months ago

#11622 closed bug (fixed)

Annotating types in type familiy equations without parentheses

Reported by: Iceland_jack Owned by:
Priority: normal Milestone: 8.8.1
Component: Compiler Version: 8.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: parser/should_compile/T11622
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D5173
Wiki Page:

Description

When annotating types in right-hand side of type family equations parentheses are required:

type family
  F a where
  F _ = (Int :: Type)

instead of

type family
  F a where
  F _ = Int :: Type

Change History (6)

comment:1 Changed 4 years ago by goldfire

Parentheses are always required around kind annotations. This has been reported in the last six months, but, sadly, a few minutes of searching has not found the ticket number.

I believe this would just require a careful look at the parser -- there may not be a fundamental reason for the restriction.

comment:2 Changed 4 years ago by Iceland_jack

Were you thinking of #8708? Removing this restriction would help make the :kind command less surprising:

>>> :kind Int
Int :: *
>>> :kind Int :: *
  <parse error>

where one might expect it to work like

>>> :type 'a'
'a' :: Char
>>> :type 'a' :: Char
'a' :: Char :: Char

While we're at it, is it possible to automatically quantify free variables?

>>> :kind Maybe
Maybe :: * -> *
>>> :kind Maybe a
  <not-in-scope error>

Explicitly quantifying the variables gets tiresome when there are more of them

comment:3 Changed 4 years ago by simonpj

This can't be hard; just some careful work in the parser. Any volunteers?

Simon

comment:4 Changed 14 months ago by RyanGlScott

Differential Rev(s): Phab:D5173
Status: newpatch

comment:5 Changed 13 months ago by Ryan Scott <ryan.gl.scott@…>

In bace26a/ghc:

Allow (unparenthesized) kind signatures

Summary: This allows for things like `[t :: MyKind]`, `(a :: k, b)`, and so on.

Test Plan: make TEST=T11622 && make TEST=T8708

Reviewers: RyanGlScott, bgamari, simonpj, goldfire, alanz

Reviewed By: RyanGlScott, simonpj

Subscribers: alanz, simonpj, rwbarton, mpickering, carter

GHC Trac Issues: #11622, #8708

Differential Revision: https://phabricator.haskell.org/D5173

comment:6 Changed 13 months ago by RyanGlScott

Milestone: 8.8.1
Resolution: fixed
Status: patchclosed
Test Case: parser/should_compile/T11622
Note: See TracTickets for help on using tickets.