-type DsM result =
- UniqSupply
- -> ValueEnv
- -> SrcLoc -- to put in pattern-matching error msgs
- -> Module -- module: for SCC profiling
- -> DsWarnings
- -> (result, DsWarnings)
-
-type DsWarnings = Bag WarnMsg -- The desugarer reports matches which are
+newtype DsM result
+ = DsM (DsEnv -> DsWarnings -> UniqSM (result, DsWarnings))
+
+unDsM (DsM x) = x
+
+data DsEnv = DsEnv {
+ ds_dflags :: DynFlags,
+ ds_globals :: Name -> TyThing, -- Lookup well-known Ids
+ ds_meta :: DsMetaEnv, -- Template Haskell bindings
+ ds_loc :: SrcLoc, -- to put in pattern-matching error msgs
+ ds_mod :: Module -- module: for SCC profiling
+ }
+
+-- Inside [| |] brackets, the desugarer looks
+-- up variables in the DsMetaEnv
+type DsMetaEnv = NameEnv DsMetaVal
+
+data DsMetaVal
+ = Bound Id -- Bound by a pattern inside the [| |].
+ -- Will be dynamically alpha renamed.
+ -- The Id has type String
+
+ | Splice TypecheckedHsExpr -- These bindings are introduced by
+ -- the PendingSplices on a HsBracketOut
+
+instance Monad DsM where
+ return = returnDs
+ (>>=) = thenDs
+
+type DsWarnings = Bag DsWarning -- The desugarer reports matches which are