Unable to create a type-level list with a single element

Viewed 47

I'm scratching my head with the following behaviour. Is there an obvious reason why this is the case?

Prelude> :set -XDataKinds

Prelude> :k 'True
'True :: Bool

Prelude> :k ['True, 'False]
['True, 'False] :: [Bool]

Prelude> :k ['True]

<interactive>:1:2: error:
    • Expected a type, but ‘ 'True’ has kind ‘Bool’
    • In the type ‘[ 'True]’

PS: I'm on GHC 8.4.3 if this is a GHC bug and was fixed later.

1 Answers

You have to disambiguate list types from type level list types by the backtick:

> :k '[ 'True]

Also note the space after [, which is needed to disambiguate from type-level character literals.

Related