- _ -> C.Var (make_var_qid (Var.varName v))
-make_exp (Lit (MachLabel s _)) = C.Label (unpackFS s)
-make_exp (Lit l) = C.Lit (make_lit l)
-make_exp (App e (Type t)) = C.Appt (make_exp e) (make_ty t)
-make_exp (App e1 e2) = C.App (make_exp e1) (make_exp e2)
-make_exp (Lam v e) | isTyVar v = C.Lam (C.Tb (make_tbind v)) (make_exp e)
-make_exp (Lam v e) | otherwise = C.Lam (C.Vb (make_vbind v)) (make_exp e)
-make_exp (Cast e co) = C.Cast (make_exp e) (make_ty co)
-make_exp (Let b e) = C.Let (make_vdef emptyNameSet b) (make_exp e)
--- gaw 2004
-make_exp (Case e v ty alts) = C.Case (make_exp e) (make_vbind v) (make_ty ty) (map make_alt alts)
-make_exp (Note (SCC _) e) = C.Note "SCC" (make_exp e) -- temporary
-make_exp (Note (CoreNote s) e) = C.Note s (make_exp e) -- hdaume: core annotations
-make_exp (Note InlineMe e) = C.Note "InlineMe" (make_exp e)
+ -- Constructors are always exported, so make sure to declare them
+ -- with qualified names
+ DataConWorkId _ -> C.Var (make_var_qid False vName)
+ DataConWrapId _ -> C.Var (make_var_qid False vName)
+ _ -> C.Var (make_var_qid isLocal vName)
+make_exp (Lit (MachLabel s _ _)) = return $ C.Label (unpackFS s)
+make_exp (Lit l) = return $ C.Lit (make_lit l)
+make_exp (App e (Type t)) = make_exp e >>= (\ b -> return $ C.Appt b (make_ty t))
+make_exp (App e1 e2) = do
+ rator <- make_exp e1
+ rand <- make_exp e2
+ return $ C.App rator rand
+make_exp (Lam v e) | isTyVar v = make_exp e >>= (\ b ->
+ return $ C.Lam (C.Tb (make_tbind v)) b)
+make_exp (Lam v e) | otherwise = make_exp e >>= (\ b ->
+ return $ C.Lam (C.Vb (make_vbind v)) b)
+make_exp (Cast e co) = make_exp e >>= (\ b -> return $ C.Cast b (make_ty co))
+make_exp (Let b e) = do
+ vd <- make_vdef False b
+ body <- make_exp e
+ return $ C.Let vd body
+make_exp (Case e v ty alts) = do
+ scrut <- make_exp e
+ newAlts <- mapM make_alt alts
+ return $ C.Case scrut (make_vbind v) (make_ty ty) newAlts
+make_exp (Note (SCC _) e) = make_exp e >>= (return . C.Note "SCC") -- temporary
+make_exp (Note (CoreNote s) e) = make_exp e >>= (return . C.Note s) -- hdaume: core annotations
+make_exp (Note InlineMe e) = make_exp e >>= (return . C.Note "InlineMe")