+ where
+ -- The lookup function passed to initDs is used for well-known Ids,
+ -- such as fold, build, cons etc, so the chances are
+ -- it'll be found in the package symbol table. That's
+ -- why we don't merge all these tables
+ pte = pcs_PTE pcs
+ lookup n = case lookupType hst pte n of {
+ Just (AnId v) -> v ;
+ other ->
+ case lookupNameEnv local_type_env n of
+ Just (AnId v) -> v ;
+ other -> pprPanic "Desugar: lookup:" (ppr n)
+ }
+
+deSugarExpr :: DynFlags
+ -> PersistentCompilerState -> HomeSymbolTable
+ -> Module -> PrintUnqualified
+ -> TypecheckedHsExpr
+ -> IO CoreExpr
+deSugarExpr dflags pcs hst mod_name unqual tc_expr
+ = do { showPass dflags "Desugar"
+ ; us <- mkSplitUniqSupply 'd'
+
+ -- Do desugaring
+ ; let (core_expr, ds_warns) = initDs dflags us lookup mod_name (dsExpr tc_expr)
+
+ -- Display any warnings
+ ; doIfSet (not (isEmptyBag ds_warns))
+ (printErrs unqual (pprBagOfWarnings ds_warns))
+
+ -- Dump output
+ ; dumpIfSet_dyn dflags Opt_D_dump_ds "Desugared" (pprCoreExpr core_expr)
+
+ ; return core_expr
+ }
+ where
+ pte = pcs_PTE pcs
+ lookup n = case lookupType hst pte n of
+ Just (AnId v) -> v
+ other -> pprPanic "Desugar: lookup:" (ppr n)