Skip to content

RequiredTypeArguments don't work with TH

See also

{-# LANGUAGE TemplateHaskellQuotes #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE TypeAbstractions #-}
{-# LANGUAGE RequiredTypeArguments #-}

module TH where

import Language.Haskell.TH

ex :: Code Q (forall a -> Show a => a -> a)
ex = [|| \ a x -> show (x :: a) ||]

doesn't work

TH.hs:11:34: error: [GHC-45510]
    • Term variable ‘a’ cannot be used here
        (term variables cannot be promoted)
    • In an expression type signature: a
      In the first argument of ‘show’, namely ‘(x :: a)’
      In the expression: show (x :: a)
   |
11 | codeId = [|| \ a x -> show (x :: a) ||]
   |                                  ^
Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information