Skip to content

Commit

Permalink
Rebase on main and update match code
Browse files Browse the repository at this point in the history
  • Loading branch information
hmontero1205 committed Nov 26, 2021
1 parent efae933 commit a6ae22a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/IR/LambdaLift.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ exprType (I.Var _ t ) = t
exprType (I.Prim _ _ t ) = t
exprType (I.Let _ _ t ) = t
exprType (I.Data _ t ) = t
exprType (I.Match _ _ _ t) = t
exprType (I.Match _ _ t) = t

zipArgsWithArrow :: [Binder] -> Poly.Type -> [(Binder, Poly.Type)]
zipArgsWithArrow (b : bs) (Poly.TBuiltin (Poly.Arrow t ts)) =
Expand Down Expand Up @@ -132,20 +132,20 @@ descend body = do
return (liftedBody, freeTypesBody)

liftLambdasInArm
:: Binder -> (I.Alt, I.Expr Poly.Type) -> LiftFn (I.Alt, I.Expr Poly.Type)
liftLambdasInArm sb (I.AltLit l, arm) = do
:: (I.Alt, I.Expr Poly.Type) -> LiftFn (I.Alt, I.Expr Poly.Type)
liftLambdasInArm (I.AltLit l, arm) = do
(liftedArm, armFrees) <-
descend $ F.forM_ sb addCurrentScope >> liftLambdas arm
descend $ return () >> liftLambdas arm
modify $ \st -> st { freeTypes = armFrees }
return (I.AltLit l, liftedArm)
liftLambdasInArm sb (I.AltDefault, arm) = do
liftLambdasInArm (I.AltDefault b, arm) = do
(liftedArm, armFrees) <-
descend $ F.forM_ sb addCurrentScope >> liftLambdas arm
descend $ F.forM_ b addCurrentScope >> liftLambdas arm
modify $ \st -> st { freeTypes = armFrees }
return (I.AltDefault, liftedArm)
liftLambdasInArm sb (I.AltData d bs, arm) = do
return (I.AltDefault b, liftedArm)
liftLambdasInArm (I.AltData d bs, arm) = do
(liftedArm, armFrees) <-
descend $ mapM_ addCurrentScope (catMaybes (sb : bs)) >> liftLambdas arm
descend $ mapM_ addCurrentScope (catMaybes bs) >> liftLambdas arm
modify $ \st -> st { freeTypes = armFrees }
return (I.AltData d bs, liftedArm)

Expand Down Expand Up @@ -189,10 +189,10 @@ liftLambdas (I.Let bs e t) = do
liftedLetBodies <- mapM liftLambdas exprs
liftedExpr <- liftLambdas e
return $ I.Let (zip vs liftedLetBodies) liftedExpr t
liftLambdas (I.Match s sb arms t) = do
liftLambdas (I.Match s arms t) = do
liftedMatch <- liftLambdas s
liftedArms <- mapM (liftLambdasInArm sb) arms
return $ I.Match liftedMatch sb liftedArms t
liftedArms <- mapM liftLambdasInArm arms
return $ I.Match liftedMatch liftedArms t
liftLambdas n = return n

liftProgramLambdas
Expand Down

0 comments on commit a6ae22a

Please sign in to comment.