Skip to content

Commit

Permalink
[mmzk] (refactor) Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
MMZK1526 committed Oct 13, 2023
1 parent a66c5bb commit 7623ab2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Year2015/Exam.hs
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ translate (name, (as, e)) newName nameMap
translate' :: Exp -> [(Id, Id)] -> [Id] -> (Block, Exp, [Id])
translate' exp nameMap ids = uncurry' (S.runState (worker exp) ids)
where
uncurry' ((a, b), c) = (a, b, c)
getFresh = S.state $ \(i : is) -> (i, is)
uncurry' ((a, b), c) = (a, b, c)
getFresh = S.state $ \(i : is) -> (i, is)
-- > worker returns a list of block and the final expression.
worker (Const c) = pure ([], Const c)
worker (Var v) = pure ([], Var v)
worker (OpApp op e e') = do
worker (Const c) = pure ([], Const c)
worker (Var v) = pure ([], Var v)
worker (OpApp op e e') = do
(b, e1) <- worker e
(b', e2) <- worker e'
pure (b ++ b', OpApp op e1 e2)
Expand All @@ -214,7 +214,7 @@ translate' exp nameMap ids = uncurry' (S.runState (worker exp) ids)
(b'', e2) <- worker e'
i <- getFresh
pure (b ++ [If cond' (b' ++ [Assign i e1]) (b'' ++ [Assign i e2])], Var i)
worker (FunApp f exps) = do
worker (FunApp f exps) = do
i <- getFresh
pure ([Call i (lookUp f nameMap) exps], Var i)

Expand Down

0 comments on commit 7623ab2

Please sign in to comment.