Last active
March 29, 2018 12:49
-
-
Save jchia/2db6c70c7afe22a6aa2c1a91ddfdcc59 to your computer and use it in GitHub Desktop.
‘foo’ is not in the type environment at a reify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE DataKinds, FlexibleInstances, OverloadedLabels, TemplateHaskell, TypeFamilies, TypeOperators #-} | |
| module Lib3 where | |
| import ClassyPrelude | |
| import Language.Haskell.TH | |
| reifyQ :: Name -> Q Exp | |
| reifyQ name = do | |
| r <- reify name | |
| pure . LitE . StringL . show $ r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE DataKinds, OverloadedLabels, TemplateHaskell #-} | |
| module Lib4 where | |
| import ClassyPrelude | |
| import Lib3 | |
| foo :: Int | |
| foo = 1 | |
| printR :: IO () | |
| -- Error on the next line as described in the title. | |
| -- Fixed by inserting 'return []' at L10. | |
| printR = putStrLn $(reifyQ 'foo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE DataKinds, OverloadedLabels, TemplateHaskell #-} | |
| module Lib4 where | |
| import ClassyPrelude | |
| import Lib3 | |
| foo :: Int | |
| foo = 1 | |
| return [] | |
| printR :: forall a. a -> IO () | |
| printR x = | |
| -- Same error as foo in the original Lib4.hs. | |
| putStrLn $(reifyQ 'x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment