Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#9882 closed bug (invalid)

Kind mismatch with singleton [Nat]

Reported by: Roel van Dijk Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.3
Keywords: Cc: basvandijk, goldfire
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by Roel van Dijk)

{-# LANGUAGE DataKinds      #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators  #-}

import GHC.TypeLits ( Nat )

data Foo (n :: [Nat]) = Foo

x :: Foo ('(:) 42 '[])
x = Foo

y :: Foo (42 ': '[])
y = Foo

z :: Foo [42]
z = Foo
Expected kind ‘*’, but ‘42’ has kind ‘Nat’
In the type signature for ‘z’: z :: Foo [42]

I would expected z to be identical to both x and y. The error occurs in both GHCi and GHC.

Some more tests:

a_works = Foo '[]
a_fails = Foo []
z_works = Foo '[42]

Change History (5)

comment:1 Changed 3 years ago by Roel van Dijk

Description: modified (diff)

comment:2 Changed 3 years ago by Roel van Dijk

I am now thinking this might not be a bug. The parser doesn't know that the [42] is of kind [Nat] so it parses it as [] 42, which has kind *.

I was confused because [1, 2, 3] was accepted as a type of kind [Nat].

comment:3 Changed 3 years ago by Roel van Dijk

Resolution: invalid
Status: newclosed

comment:4 Changed 3 years ago by Simon Peyton Jones <simonpj@…>

In a972bddfc8115d80d774383a55202a293dc68595/ghc:

Improve documentation of syntax for promoted lists

THe documentation in 7.9.4 of promoted list and tuple types was
misleading, which led to Trac #9882.  This patch makes explicit
that only type-level with two or more elements can have the
quote omitted.

comment:5 Changed 3 years ago by Simon Peyton Jones <simonpj@…>

In a3e6915431f93ebc0aaee22b7b9f118bffb01cae/ghc:

Wibbles to documentation for promoted lists and tuples (Trac #9882)
Note: See TracTickets for help on using tickets.