[GHC] #14869: Documentation for isLiftedTypeKind is incorrect

GHC ghc-devs at haskell.org
Wed Feb 28 14:26:55 UTC 2018


#14869: Documentation for isLiftedTypeKind is incorrect
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.2
  (Type checker)                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Documentation
  Unknown/Multiple                   |  bug
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I [https://github.com/ghc-proposals/ghc-
 proposals/pull/32#issuecomment-369252383 noticed recently] that Template
 Haskell reifies `Constraint` as `Type`:

 {{{#!hs
 $ ~/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
 [http://git.haskell.org/ghc.git/blob/df2c3b3364834d2fd038192c89348fc50a2e0475:/compiler/types/TyCoRep.hs#l721
 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.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14869>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list