Skip to content

Commit

Permalink
fix recursors and evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Sep 13, 2022
1 parent 78e543e commit 0dba8d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Juvix/Compiler/Core/Evaluator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ eval !ctx !env0 = convertRuntimeNodes . eval' env0
evalError "the number of patterns doesn't match the number of arguments" (substEnv env n)

patmatch :: [Node] -> Node -> Pattern -> Maybe [Node]
patmatch acc _ PatWildcard {} = Just acc
patmatch acc v PatBinder {} = Just (v : acc)
patmatch acc _ PatWildcard {} =
Just acc
patmatch acc v (PatBinder PatternBinder {..}) =
patmatch (v : acc) v _patternBinderPattern
patmatch acc (NCtr (Constr _ tag args)) (PatConstr PatternConstr {..})
| tag == _patternConstrTag =
matchPatterns acc args _patternConstrArgs
Expand Down
4 changes: 2 additions & 2 deletions src/Juvix/Compiler/Core/Extra/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ getBinderPatternInfos = go []
PatConstr (PatternConstr {..}) ->
foldl' go acc _patternConstrArgs
PatBinder (PatternBinder {..}) ->
_patternBinderInfo : acc
go (_patternBinderInfo : acc) _patternBinderPattern
PatWildcard {} ->
acc

Expand All @@ -186,7 +186,7 @@ getPatternInfos = go []
PatConstr (PatternConstr {..}) ->
foldl' go (_patternConstrInfo : acc) _patternConstrArgs
PatBinder (PatternBinder {..}) ->
_patternBinderInfo : acc
go (_patternBinderInfo : acc) _patternBinderPattern
PatWildcard (PatternWildcard {..}) ->
_patternWildcardInfo : acc

Expand Down

0 comments on commit 0dba8d3

Please sign in to comment.