Skip to content

GHCi incorrectly reports the kind of unboxed tuples spliced in from Template Haskell

First noticed in #12976 (closed). First, fire up GHCi 8.0.2 (or HEAD) and enable some options:

$ inplace/bin/ghc-stage2 --interactive
GHCi, version 8.1.20161208: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> :set -fprint-explicit-runtime-reps -fprint-explicit-kinds -fprint-explicit-foralls -XUnboxedTuples -XTemplateHaskell -XMagicHash 
λ> :m + GHC.Exts Language.Haskell.TH Language.Haskell.TH.Lib Language.Haskell.TH.Syntax

Next, try looking at the kind of a regular unboxed tuple:

λ> :k (#,#)
(#,#) :: forall (a :: RuntimeRep) (b :: RuntimeRep).
         TYPE a -> TYPE b -> TYPE 'UnboxedTupleRep

But when you splice in the unboxed tuple type constructor via Template Haskell, :k misbehaves:

λ> :k $(unboxedTupleT 2)
$(unboxedTupleT 2) :: * -> * -> TYPE 'UnboxedTupleRep

This kind is totally wrong, since you //can// in fact apply this type constructor to types with kinds other than *:

λ> :k $(unboxedTupleT 2) Int# Int#
$(unboxedTupleT 2) Int# Int# :: TYPE 'UnboxedTupleRep

Moreover, this appears to be a regression since GHC 8.0.1, since if you try this in GHCi 8.0.1:

$ /opt/ghc/8.0.1/bin/ghci
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> :set -fprint-explicit-runtime-reps -fprint-explicit-kinds -fprint-explicit-foralls -XUnboxedTuples -XTemplateHaskell -XMagicHash
λ> :m + GHC.Exts Language.Haskell.TH Language.Haskell.TH.Lib Language.Haskell.TH.Syntax
λ> :k $(unboxedTupleT 2)
$(unboxedTupleT 2) :: forall (a :: RuntimeRep) (b :: RuntimeRep).
                      TYPE a -> TYPE b -> TYPE 'UnboxedTupleRep
Trac metadata
Trac field Value
Version 8.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information