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 Type
If 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
:7:1: error: [GHC-24922]
CannotReifyOutOfScopeThing.hsnot in scope at a reify
‘doesn'tExist’ is |
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 []