summaryrefslogtreecommitdiff
path: root/compiler/iface/BuildTyCl.hs
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2015-08-27 08:01:21 +0200
committerBen Gamari <ben@smart-cactus.org>2015-08-27 08:01:21 +0200
commit211b3497f19510f94c00d4c234f59da48695b563 (patch)
tree2edc70b834020f3fe58999329ff6db9acdad4152 /compiler/iface/BuildTyCl.hs
parent28ad98e7384cd128ddba17620ed6a8345c0d7850 (diff)
downloadhaskell-211b3497f19510f94c00d4c234f59da48695b563.tar.gz
Move newImplicitBinder to from IfaceEnv to BuildTyCl
Diffstat (limited to 'compiler/iface/BuildTyCl.hs')
-rw-r--r--compiler/iface/BuildTyCl.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/iface/BuildTyCl.hs b/compiler/iface/BuildTyCl.hs
index 0a922e86e1..640ad9b799 100644
--- a/compiler/iface/BuildTyCl.hs
+++ b/compiler/iface/BuildTyCl.hs
@@ -341,3 +341,21 @@ Here we can't use a newtype either, even though there is only
one field, because equality predicates are unboxed, and classes
are boxed.
-}
+
+newImplicitBinder :: Name -- Base name
+ -> (OccName -> OccName) -- Occurrence name modifier
+ -> TcRnIf m n Name -- Implicit name
+-- Called in BuildTyCl to allocate the implicit binders of type/class decls
+-- For source type/class decls, this is the first occurrence
+-- For iface ones, the LoadIface has alrady allocated a suitable name in the cache
+newImplicitBinder base_name mk_sys_occ
+ | Just mod <- nameModule_maybe base_name
+ = newGlobalBinder mod occ loc
+ | otherwise -- When typechecking a [d| decl bracket |],
+ -- TH generates types, classes etc with Internal names,
+ -- so we follow suit for the implicit binders
+ = do { uniq <- newUnique
+ ; return (mkInternalName uniq occ loc) }
+ where
+ occ = mk_sys_occ (nameOccName base_name)
+ loc = nameSrcSpan base_name