Skip to content

liftData should use Quote, not Q

The following code compiles on GHC 8.8, but not on HEAD:

{-# LANGUAGE DeriveDataTypeable #-}
module Bug where

import Data.Data
import Language.Haskell.TH.Syntax

data T = MkT deriving Data
instance Lift T where
  lift = liftData
$ ~/Software/ghc5/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:9:10: error:
    • Couldn't match type ‘m’ with ‘Q’
      ‘m’ is a rigid type variable bound by
        the type signature for:
          lift :: forall (m :: * -> *). Quote m => T -> m Exp
        at Bug.hs:9:3-6
      Expected type: T -> m Exp
        Actual type: T -> Q Exp
    • In the expression: liftData
      In an equation for ‘lift’: lift = liftData
      In the instance declaration for ‘Lift T’
    • Relevant bindings include
        lift :: T -> m Exp (bound at Bug.hs:9:3)
  |
9 |   lift = liftData
  |          ^^^^^^^^

In HEAD, the type of lift has been generalized from a -> Q Exp to Quote m => a -> m Exp. On the other hand, liftData is still monomorphized to Q, which makes it impossible to use to define lift instances in HEAD. It would be straightforward to generalize liftData to work over any Quote, so let's do so.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information