haskelldata-kinds

Type-level list of a single type level-tuple in Haskell


Using DataKinds and TypeOperators, I can make type level-tuples of types, and type-level lists of types, but I cannot nest them:

> :k '['(Int, Int), '(Int, Int)]
error: parse error on input ‘'’`

I can make a list of multiple tuples:

> :k ['(Int,Int),'(Int,Int)]
['(Int,Int),'(Int,Int)] :: [(*, *)]

But this doesn't work with only one tuple gives:

:k ['(Int,Bool)]
<interactive>:1:2: error:
    • Expected a type, but ‘'(Int, Bool)’ has kind ‘(*, *)’

It can be done using KindSignatures, but it is very verbose:

> :k '[('(Int,Bool) :: (*,*))]
'[('(Int,Bool) :: (*,*))] :: [(*, *)]

Is there a less verbose way to do this, or is this the best way?


Solution

  • You need to add a space:

    > :k '['(Int, Int), '(Int, Int)]
    <interactive>:1:1: error: parse error on input '
    > :k '[ '(Int, Int), '(Int, Int)]
    '[ '(Int, Int), '(Int, Int)] :: [(*, *)]
    

    Essentially, the parser is confused by the char literal '[' which happens to be at the beginning.