caseR :: (Monad m)
  => Rewrite m [C.CoreContext] C.Term
  -> Rewrite m [C.CoreContext] C.Term
  -> Rewrite m [C.CoreContext] C.Term
caseR rr1 rr2 = transparently $ rewrite $ \e -> case e of
  (C.Case scrut t alts) -> liftM2 (\scrut' alts' -> C.Case scrut' t alts')
                                    (apply C.Other rr1 scrut)
                                    (mapM (secondM (apply C.CaseAlt rr2)) alts)
  _                     -> fail "caseR"
caseR :: (Monad m)
  => Rewrite m [C.CoreContext] C.Term
  -> Rewrite m [C.CoreContext] C.Term
  -> Rewrite m [C.CoreContext] C.Term
caseR rr1 rr2 = transparently $ rewrite $ \e -> case e of
  (C.Case scrut t alts) -> liftM2 (\scrut' alts' -> C.Case scrut' t alts')
                                    (apply C.Other rr1 scrut)
                                    (mapM (secondM (apply C.CaseAlt rr2)) alts)
  _                     -> fail "caseR"
caseR rr1 rr2 = transparently $ rewrite $ \e -> case e of
  (C.Case scrut t alts) -> liftM2 (\scrut' alts' -> C.Case scrut' t alts')
                                    (apply C.Other rr1 scrut)
                                    (mapM (secondM (apply C.CaseAlt rr2)) alts)
  _                     -> fail "caseR"