Skip to content

Trouble resolving Typeable 'LiftedRep

See also #21822 (closed), #14190.

Summary

Inference fails with a simple TypeRep application.

Steps to reproduce

{-# language TypeInType, ScopedTypeVariables #-}
module Silly where
import Type.Reflection (Typeable, typeRep, TypeRep)
import Type.Reflection.Unsafe (mkTrApp)
import GHC.Exts (TYPE, RuntimeRep (..))
import Data.Kind (Type)

mkTrFun :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep)
                  (a :: TYPE r1) (b :: TYPE r2).
           TypeRep a -> TypeRep b -> TypeRep ((a -> b) :: Type)
mkTrFun a b = typeRep `mkTrApp` a `mkTrApp` b

Expected behavior

I expected this to compile.

Actual behavior

Silly.hs:11:15: error:
    • No instance for (Typeable 'LiftedRep)
        arising from a use of ‘typeRep’
    • In the first argument of ‘mkTrApp’, namely ‘typeRep’
      In the first argument of ‘mkTrApp’, namely ‘typeRep `mkTrApp` a’
      In the expression: typeRep `mkTrApp` a `mkTrApp` b
   |
11 | mkTrFun a b = typeRep `mkTrApp` a `mkTrApp` b
   |               ^^^^^^^

This is a rather perplexing error, because 'LiftedRep is most assuredly typeable.

Environment

  • GHC version used: 8.6.3

Optional:

  • Operating System:
  • System Architecture:
Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information