Saurabh Nanda
Saurabh Nanda

Reputation: 6793

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

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.

Upvotes: 2

Views: 50

Answers (1)

Andr&#225;s Kov&#225;cs
Andr&#225;s Kov&#225;cs

Reputation: 30113

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.

Upvotes: 4

Related Questions