Cannot reify type because name is not in scope [GHC-24922]
The Template Haskell reifyType function
returns the type or kind of a given name:
reifyType :: Name -> Q TypeIf the name is not in scope, GHC fails with error GHC-24922. The name has possibly been misspelled, or needs to be defined or brought into scope.
Examples
Cannot reify type because name is not in scope
GHC fails with an error because the requested name is not in scope.
Error Message
CannotReifyOutOfScopeThing.hs:7:1: error: [GHC-24922]
‘doesn'tExist’ is not in scope at a reify
|
7 | do t <- reifyType (mkName "doesn'tExist")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...CannotReifyOutOfScopeThing.hs
Before
{-# LANGUAGE TemplateHaskell #-}
module CannotReifyOutOfScopeThing where
import Language.Haskell.TH
do t <- reifyType (mkName "doesn'tExist")
return []
After
{-# LANGUAGE TemplateHaskell #-}
module CannotReifyOutOfScopeThing where
import Language.Haskell.TH
doesn'tExist = "I do so!"
do t <- reifyType (mkName "doesn'tExist")
return []