Skip to content

Sort out promotion of unlifted types

Here's an unlifted type:

type T :: UnliftedType
data T = A | B Int

If I try to promote A:

type PA = 'A

I get an error: Couldn't match a lifted type with an unlifted type. I can fix this by adding a kind signature:

type PA :: T
type PA = 'A

If I try to promote B:

type PB = 'B

This works without a kind signature. If I add a kind signature with the kind that was inferred by GHC:

type PB :: Int -> T
type PB = 'B

then GHC rejects: Expected a lifted type, but ‘T’ is a boxed unlifted type.

I propose that for now we forbid:

  1. Promotion of constructors of unlifted datatypes and newtypes
  2. Promotion of unboxed tuples type T1 = '(# #), type T2 = '(#,#)
  3. Unlifted type data declarations
type T :: UnliftedType
type data T = MkT

until there's motivation/theory behind it.

The other option is to at least be consistent and treat PA and PB in the same way.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information