@@ -281,7 +281,8 @@ irTerm vs env tm@(App f a) = case unApply tm of
281 x' <- irTerm vs env x
281 x' <- irTerm vs env x
282 t' <- irTerm vs env t
282 t' <- irTerm vs env t
283 e' <- irTerm vs env e
283 e' <- irTerm vs env e
284+ return (LCase Shared x'
284− return (LCase x' [LConCase 0 (sNS (sUN "False") ["Bool","Prelude"]) [] e'
285+ [LConCase 0 (sNS (sUN "False") ["Bool","Prelude"]) [] e'
285 ,LConCase 1 (sNS (sUN "True" ) ["Bool","Prelude"]) [] t'
286 ,LConCase 1 (sNS (sUN "True" ) ["Bool","Prelude"]) [] t'
@@ -510,7 +511,7 @@ irSC vs (UnmatchedCase str) = return $ LError str
510irSC vs (ProjCase tm alts) = do
511irSC vs (ProjCase tm alts) = do
511 tm' <- irTerm vs [] tm
512 tm' <- irTerm vs [] tm
512 alts' <- mapM (irAlt vs tm') alts
513 alts' <- mapM (irAlt vs tm') alts
513− return $ LCase tm' alts'
514+ return $ LCase Shared tm' alts'
515-- Transform matching on Delay to applications of Force.
516-- Transform matching on Delay to applications of Force.
516irSC vs (Case up n [ConCase (UN delay) i [_, _, n'] sc])
517irSC vs (Case up n [ConCase (UN delay) i [_, _, n'] sc])
@@ -556,7 +557,7 @@ irSC vs (Case up n [alt]) = do
556 alt' <- irAlt vs (LV (Glob n)) alt
557 alt' <- irAlt vs (LV (Glob n)) alt
557 return $ case namesBoundIn alt' `usedIn` subexpr alt' of
558 return $ case namesBoundIn alt' `usedIn` subexpr alt' of
558 [] -> subexpr alt' -- strip the unused top-most case
559 [] -> subexpr alt' -- strip the unused top-most case
559− _ -> LCase (LV (Glob n)) [alt']
560+ _ -> LCase up (LV (Glob n)) [alt']
561 namesBoundIn :: LAlt -> [Name]
562 namesBoundIn :: LAlt -> [Name]
562 namesBoundIn (LConCase cn i ns sc) = ns
563 namesBoundIn (LConCase cn i ns sc) = ns
@@ -588,7 +589,7 @@ irSC vs (Case up n alts@[ConCase cn a ns sc, DefaultCase sc']) = do
588 detag <- fgetState (opt_detaggable . ist_optimisation cn)
589 detag <- fgetState (opt_detaggable . ist_optimisation cn)
590 then irSC vs (Case up n [ConCase cn a ns sc])
591 then irSC vs (Case up n [ConCase cn a ns sc])
591− else LCase (LV (Glob n)) <$> mapM (irAlt vs (LV (Glob n))) alts
592+ else LCase up (LV (Glob n)) <$> mapM (irAlt vs (LV (Glob n))) alts
593irSC vs sc@(Case up n alts) = do
594irSC vs sc@(Case up n alts) = do
594 -- check that neither alternative needs the newtype optimisation,
595 -- check that neither alternative needs the newtype optimisation,
@@ -598,7 +599,7 @@ irSC vs sc@(Case up n alts) = do
598 $ ifail ("irSC: non-trivial case-match on detaggable data: " ++ show sc)
599 $ ifail ("irSC: non-trivial case-match on detaggable data: " ++ show sc)
600 -- everything okay
601 -- everything okay
601− LCase (LV (Glob n)) <$> mapM (irAlt vs (LV (Glob n))) alts
602+ LCase up (LV (Glob n)) <$> mapM (irAlt vs (LV (Glob n))) alts
603 isDetaggable (ConCase cn _ _ _) = fgetState $ opt_detaggable . ist_optimisation cn
604 isDetaggable (ConCase cn _ _ _) = fgetState $ opt_detaggable . ist_optimisation cn
604 isDetaggable _ = return False
605 isDetaggable _ = return False