Skip to content

BoxedRep breaks TH.Lift instances

The following program no longer compiles:

{-# LANGUAGE DeriveLift                 #-}
{-# LANGUAGE TemplateHaskell            #-}
module M where

import qualified Language.Haskell.TH.Syntax as TH


data VendorEnv = A

instance TH.Lift VendorEnv where
  liftTyped _ = [|| A ||]

with the following error

M:1:1: error:
    Cannot use function with levity-polymorphic arguments:
      Language.Haskell.TH.Syntax.$dmlift :: forall (r :: GHC.Types.RuntimeRep)
                                                   (t :: TYPE r) (m :: * -> *).
                                            (TH.Lift t, r ~ 'GHC.Types.BoxedRep 'GHC.Types.Lifted,
                                             TH.Quote m) =>
                                            t -> m TH.Exp
    (Note that levity-polymorphic primops such as 'coerce' and unboxed tuples
    are eta-expanded internally because they must occur fully saturated.
    Use -fprint-typechecker-elaboration to display the full expression.)
    Levity-polymorphic arguments: t :: TYPE r
Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information