Opened 6 years ago

Closed 12 months ago

#8708 closed bug (fixed)

Kind annotation in tuple not parsed

Reported by: goldfire Owned by:
Priority: normal Milestone: 8.8.1
Component: Compiler (Parser) Version: 7.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: parser/should_compile/T8708
Blocked By: Blocking:
Related Tickets: #11267, #11622 Differential Rev(s): Phab:D5173
Wiki Page:

Description

Consider this:

{-# LANGUAGE KindSignatures #-}

foo :: (Int, Int :: *)
foo = undefined

HEAD reports

/Users/rae/temp/Bug.hs:5:18: parse error on input ‛::’

Changing the line to

foo :: (Int, (Int :: *))

fixes the problem. Note the extra parentheses.

Change History (5)

comment:1 Changed 4 years ago by thomie

What about the following:

  • unboxed tuples: (# Int, Int :: * #)
  • lists: [ Int :: * ]
  • parallel arrays: [: Int :: * :]
  • default declarations: default ( Int :: * )

Currently all of those don't allow types with kind annotation but without parenthesis. They only allow ctypes:

-- A ctype is a for-all type
ctype	:: { RdrNameHsType }
	: 'forall' tv_bndrs '.' ctype	{ mkHsForAllTy (Just $2) [] $4 }
	| context '=>' type		{ mkHsForAllTy Nothing   $1 $3 }
	-- A type of form (context => type) is an *implicit* HsForAllTy
	| type				{ $1 }

Implementation wise it would be nice to keep doing the same for all: either allow kind annotation without parenthesis, or keep the status quo (since 2002).

comment:2 Changed 23 months ago by RyanGlScott

comment:3 Changed 12 months ago by RyanGlScott

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

comment:4 Changed 12 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:5 Changed 12 months ago by RyanGlScott

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