Skip to content

Instantly share code, notes, and snippets.

@mgsloan
Created February 12, 2015 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgsloan/53d7fa50338c696e5c80 to your computer and use it in GitHub Desktop.
Save mgsloan/53d7fa50338c696e5c80 to your computer and use it in GitHub Desktop.
$ runhaskell TestAddTopDecls.hs
TestAddTopDecls.hs:5:14:
GHC internal error: ‘one_a2M1’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: []
In the first argument of ‘print’, namely ‘one_a2M1’
In the expression: print one_a2M1
In an equation for ‘main’: main = print one_a2M1
{-# LANGUAGE TemplateHaskell #-}
import AddTopDecls
main = print $testAddTopDecls
{-# LANGUAGE TemplateHaskell #-}
module AddTopDecls where
import Language.Haskell.TH.Syntax
-- Causes a GHC internal error.
testAddTopDecls = do
n <- newName "one"
addTopDecls [FunD n [Clause [] (NormalB (LitE (IntegerL 1))) []]]
return (VarE n)
-- This is a separate issue. I would expect this one to work, but I'm
-- guessing that 'addTopDecls' doesn't erase the uniqueness of names,
-- or something along those lines.
testAddTopDecls' = do
addTopDecls =<< [d| one = 1 |]
return (VarE (mkName "one"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment