@@ -574,6 +574,10 @@ prune proj (Case n alts)
574574 = let alts' = filter notErased (map pruneAlt alts) in
575575 case alts' of
576576 [] -> ImpossibleCase
577+ as@[ConCase (UN delay) i [arg] sc]
578+ | delay == txt "Delay"
579+ -> if proj then mkForce n arg sc
580+ else Case n as
577581 as@[ConCase cn i args sc] -> if proj then mkProj n 0 args sc
578582 else Case n as
579583 as@[SucCase cn sc] -> if proj then mkProj n (-1) [cn] sc
@@ -594,6 +598,31 @@ prune proj (Case n alts)
594598 notErased (DefaultCase ImpossibleCase) = False
595599 notErased _ = True
596600
601+ mkForce n arg (Case x alts)
602+ | x == arg = ProjCase (forceArg n)
603+ (map (mkForceAlt n arg) alts)
604+ | otherwise = Case x (map (mkForceAlt n arg) alts)
605+ mkForce n arg (ProjCase t alts)
606+ = ProjCase (forceTm n arg t) (map (mkForceAlt n arg) alts)
607+ mkForce n arg (STerm t) = STerm (forceTm n arg t)
608+ mkForce n arg c = c
609+
610+ mkForceAlt n arg (ConCase cn t args rhs)
611+ = ConCase cn t args (mkForce n arg rhs)
612+ mkForceAlt n arg (FnCase cn args rhs)
613+ = FnCase cn args (mkForce n arg rhs)
614+ mkForceAlt n arg (ConstCase t rhs)
615+ = ConstCase t (mkForce n arg rhs)
616+ mkForceAlt n arg (SucCase sn rhs)
617+ = SucCase sn (mkForce n arg rhs)
618+ mkForceAlt n arg (DefaultCase rhs)
619+ = DefaultCase (mkForce n arg rhs)
620+
621+ forceTm n arg t = subst arg (forceArg n) t
622+
623+ forceArg n = App (App (P Ref (sUN "Force") Erased) Erased)
624+ (P Bound n Erased)
625+
597626 mkProj n i [] sc = prune proj sc
598627 mkProj n i (x : xs) sc = mkProj n (i + 1) xs (projRep x n i sc)
599628