Skip to content

Instantly share code, notes, and snippets.

@jchia
Last active March 29, 2018 12:49
Show Gist options
  • Select an option

  • Save jchia/2db6c70c7afe22a6aa2c1a91ddfdcc59 to your computer and use it in GitHub Desktop.

Select an option

Save jchia/2db6c70c7afe22a6aa2c1a91ddfdcc59 to your computer and use it in GitHub Desktop.
‘foo’ is not in the type environment at a reify
{-# 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
{-# 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)
{-# 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