Skip to content

Data type can't be given return kind that is identical to its TLKS

I would have expected this to work, but it doesn't:

{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TopLevelKindSignatures #-}
module Bug where

import Data.Kind

type D :: forall k. k -> Type
data D :: forall k. k -> Type
[1 of 1] Compiling Bug              ( ../Bug.hs, ../Bug.o )

../Bug.hs:9:1: error:
    • Couldn't match expected kind ‘forall k1. k1 -> *’
                  with actual kind ‘k -> *’
    • In the data type declaration for ‘D’
  |
9 | data D :: forall k. k -> Type
  | ^^^^^^

Note that this bug does not appear to apply to type families, as the following works without issue:

type T :: forall k. k -> Type
type family T :: forall k. k -> Type
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information