Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$ runhaskell TestAddTopDecls.hs
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