Type-level list of a single type level-tuple in Haskell
Asked Answered
A

1

6

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?

Agglutinogen answered 18/2, 2020 at 19:21 Comment(0)
F
6

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.

Fledge answered 18/2, 2020 at 19:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.