Last active
January 10, 2016 07:23
-
-
Save lyricallogical/2741a60746da2808fdfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
walk :: Var -> Subst -> Var | |
walk var subst = go var subst | |
where go :: Var -> List Var -> Maybe Var -> Var | |
go (Unbound k) stack acc = | |
case (subst k, acc) of | |
(Nothing, Nothing) -> Unbound k | |
(Nothing, Just u) -> Cons u v | |
(Just v, _) -> go v stack acc | |
go (Cons h t) stack acc = go h (t :: stack) acc | |
go v [] Nothing = v | |
go v [] (Just u) = Cons u v | |
go v (x :: xs) Nothing = go x xs (Just v) | |
go v (x :: xs) (Some u) = go x xs v (Just (Cons u v)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment