Skip to content

Commit b0e088e

Browse files
committed
ES: updated EvaluatedCaseElimination
1 parent 252cf14 commit b0e088e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

grin/src/Transformations/ExtendedSyntax/Optimising/EvaluatedCaseElimination.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
module Transformations.ExtendedSyntax.Optimising.EvaluatedCaseElimination where
33

44
import Data.Functor.Foldable as Foldable
5-
import Grin.Grin
5+
import Grin.ExtendedSyntax.Grin
66

77
evaluatedCaseElimination :: Exp -> Exp
88
evaluatedCaseElimination = ana builder where
99
builder :: Exp -> ExpF Exp
1010
builder = \case
11-
ECase val alts | all (altBodyEQ $ SReturn val) alts -> SReturnF val
11+
ECase scrut alts | all (altBodyEQ $ SReturn (Var scrut)) alts -> SReturnF (Var scrut)
1212
exp -> project exp
1313

1414
altBodyEQ :: Exp -> Alt -> Bool
15-
altBodyEQ exp (Alt _cpat body) = exp == body
15+
altBodyEQ exp (Alt _cpat _altName body) = exp == body
16+

0 commit comments

Comments
 (0)