diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-05-19 19:00:26 +0200 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-05-19 19:00:26 +0200 |
commit | 69006a4c5ea96c9466fe2ec0edbd95537c5a2e72 (patch) | |
tree | 129aab047f7a16f3aa4be39a354202ffaf62e3b0 /prototypes | |
parent | 158fca8352725e5db5d1bdc88e21b802091fbfc0 (diff) |
recursive garbage removal
Diffstat (limited to 'prototypes')
-rw-r--r-- | prototypes/LamMachine.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/prototypes/LamMachine.hs b/prototypes/LamMachine.hs index 13fded03..23416fea 100644 --- a/prototypes/LamMachine.hs +++ b/prototypes/LamMachine.hs | |||
@@ -216,13 +216,13 @@ dLadders s x@(a: b: us) x'@(a': b': us') | |||
216 | tryRemoves xs = tryRemoves_ (Var <$> xs) | 216 | tryRemoves xs = tryRemoves_ (Var <$> xs) |
217 | 217 | ||
218 | tryRemoves_ [] dt = dt | 218 | tryRemoves_ [] dt = dt |
219 | tryRemoves_ (Var i: vs) dt = maybe (tryRemoves_ vs dt) (tryRemoves_ $ catMaybes $ down i <$> vs) $ tryRemove_ i dt | 219 | tryRemoves_ (Var i: vs) dt = maybe (tryRemoves_ vs dt) (\(is, st) -> tryRemoves_ (is ++ catMaybes (down i <$> vs)) st) $ tryRemove_ i dt |
220 | 220 | where | |
221 | tryRemove_ i (MSt xs e es) = MSt <$> down (i+1) xs <*> down i e <*> downDown i es | 221 | tryRemove_ i (MSt xs e es) = (\a b (is, c) -> (is, MSt a b c)) <$> down (i+1) xs <*> down i e <*> downDown i es |
222 | 222 | ||
223 | downDown i [] = Just [] | 223 | downDown i [] = Just ([], []) |
224 | downDown 0 (_: xs) = Just xs | 224 | downDown 0 (x: xs) = Just (Var <$> fvs x, xs) |
225 | downDown i (x: xs) = (:) <$> down (i-1) x <*> downDown (i-1) xs | 225 | downDown i (x: xs) = (\x (is, xs) -> (up 0 1 <$> is, x: xs)) <$> down (i-1) x <*> downDown (i-1) xs |
226 | 226 | ||
227 | ----------------------------------------------------------- machine code begins here | 227 | ----------------------------------------------------------- machine code begins here |
228 | 228 | ||
@@ -316,7 +316,7 @@ steps nostep {-ready-} bind cont dt@(MSt t e vs) = case e of | |||
316 | 316 | ||
317 | shiftR (MSt (Let x xs) e es) = MSt xs x $ e: es | 317 | shiftR (MSt (Let x xs) e es) = MSt xs x $ e: es |
318 | 318 | ||
319 | tryRemove i st = maybe (end st) (bind "remove" end) $ tryRemove_ i st | 319 | tryRemove i st = {-maybe (end st)-} (bind "remove" end) $ tryRemoves [i] st |
320 | 320 | ||
321 | -- lookup & step | 321 | -- lookup & step |
322 | lookupHNF' :: StepTag -> (Exp -> Exp -> Exp) -> Int -> MSt -> e | 322 | lookupHNF' :: StepTag -> (Exp -> Exp -> Exp) -> Int -> MSt -> e |