Skip to content

Commit

Permalink
reimeplement value pattern check
Browse files Browse the repository at this point in the history
  • Loading branch information
egisatoshi committed Nov 20, 2022
1 parent c4ab798 commit d16b0a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
hs-src/Paths_pwl.hs
dist-newstyle/
dist-newstyle/
tmp.txt
5 changes: 5 additions & 0 deletions Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,11 @@ checkPattern :: Env -> [(Expr, TVal)] -> [Pattern] -> CheckM ([Pattern], [(Name,
checkPattern env cs ps = do
(ps', tRet, us, vs) <- checkPattern' env cs ps [] [] [] []
vRet <- unify us
mapM_ (\(x, y) ->
if x == y
then return ()
else throwError (Default "value pattern cannot unified"))
(map (\(x, y) -> (substitute vRet x, substitute vRet y)) vs)
return (ps', map (\(s, t) -> (s, substitute vRet t)) tRet, vRet)

checkPattern' :: Env -> [(Expr, TVal)] -> [Pattern] -> [Pattern] -> [(Name, TVal)] -> [(Expr, Expr)] -> [(Expr, Expr)] -> CheckM ([Pattern], [(Name, TVal)], [(Expr, Expr)], [(Expr, Expr)])
Expand Down

0 comments on commit d16b0a8

Please sign in to comment.