Documentation for isLiftedTypeKind is incorrect
I noticed recently that Template Haskell reifies Constraint
as Type
:
$ ~/Software/ghc2/inplace/bin/ghc-stage2 --interactive
GHCi, version 8.5.20180221: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> :set -XTypeFamilies -XTemplateHaskell
λ> :m + Data.Kind Language.Haskell.TH
λ> type family Foo :: Constraint
λ> putStrLn $(reify ''Foo >>= stringE . pprint)
type family Ghci1.Foo :: *
The root of the issue can be traced back to the isLiftedTypeKind
function, which TcSplice
uses to distinguish Type
from Constraint
. At least, that's what its documentation claims:
-- | This version considers Constraint to be distinct from *. Returns True
-- if the argument is equivalent to Type and False otherwise.
isLiftedTypeKind :: Kind -> Bool
isLiftedTypeKind = is_TYPE is_lifted
where
is_lifted (TyConApp lifted_rep []) = lifted_rep `hasKey` liftedRepDataConKey
is_lifted _ = False
However, in practice this claim about treating Constraint
and Type
as distinct is false:
$ ~/Software/ghc2/inplace/bin/ghc-stage2 --interactive -package ghc
GHCi, version 8.5.20180221: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> :m + TyCoRep TysWiredIn
λ> isLiftedTypeKind liftedTypeKind
True
λ> isLiftedTypeKind constraintKind
True
Either we should change the implementation of isLiftedTypeKind
to match the documentation's claim, or change the documentation.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information