1. When desugaring a [d| ... |], do not gensym the method names of
an instance declaration, else we get very confused!
2. We don't need to make fresh Names in DsMeta.mkGenSym, because
the existing Name will do, I believe. We'll do the genSym when
we *run* the splice. (This stuff makes my head hurt.)
Assuming this is so, we can simplify the mkGenSym stuff still more.
InstDecl(..), ConDecl(..), BangType(..),
PendingSplice, splitHsInstDeclTy,
placeHolderType, tyClDeclNames,
InstDecl(..), ConDecl(..), BangType(..),
PendingSplice, splitHsInstDeclTy,
placeHolderType, tyClDeclNames,
- collectHsBinders, collectPatBinders, collectPatsBinders,
+ collectHsBinders, collectPatBinders,
+ collectMonoBinders, collectPatsBinders,
import qualified OccName( varName, tcName )
import Module ( Module, mkModule, moduleUserString )
import qualified OccName( varName, tcName )
import Module ( Module, mkModule, moduleUserString )
-import Id ( Id, idType )
+import Id ( Id, idType, mkLocalId )
import Name ( mkExternalName )
import OccName ( mkOccFS )
import NameEnv
import Name ( mkExternalName )
import OccName ( mkOccFS )
import NameEnv
; let ss = mkGenSyms (collectMonoBinders binds)
; binds1 <- addBinds ss (rep_monobind binds)
; decls1 <- coreList decQTyConName binds1
; let ss = mkGenSyms (collectMonoBinders binds)
; binds1 <- addBinds ss (rep_monobind binds)
; decls1 <- coreList decQTyConName binds1
- ; i <- repInst cxt1 inst_ty1
- (wrapNonGenSyms ss decls1)
+ ; decls2 <- wrapNongenSyms ss decls1
-- wrapNonGenSyms: do not clone the class op names!
-- They must be called 'op' etc, not 'op34'
-- wrapNonGenSyms: do not clone the class op names!
-- They must be called 'op' etc, not 'op34'
+ ; i <- repInst cxt1 inst_ty1 decls2
; return (loc, i)}
where
(tvs, cxt, cls, tys) = splitHsInstDeclTy ty
; return (loc, i)}
where
(tvs, cxt, cls, tys) = splitHsInstDeclTy ty
-- Generate a fresh name for a locally bound entity
mkGenSym :: Name -> GenSymBind
-- Generate a fresh name for a locally bound entity
mkGenSym :: Name -> GenSymBind
+-- Does not need to be monadic, becuase we can use the
+-- existing name. For example:
+-- [| \x_77 -> x_77 + x_77 |]
+-- desugars to
+-- do { x_77 <- genSym "x"; .... }
+-- We use the same x_77 in the desugared program, but with the type Bndr
+-- instead of Int
+
mkGenSym nm = (nm, mkLocalId nm stringTy)
-- Ditto for a list of names
mkGenSym nm = (nm, mkLocalId nm stringTy)
-- Ditto for a list of names