Skip to content

Commit

Permalink
Simplify: Just query bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
SophieBosio committed Jun 10, 2024
1 parent fbe369f commit 32788c9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Validation/Translator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ translate _ t@(TConstructor {}) = error
translatePattern :: Pattern Type -> Formula SValue
translatePattern (Value v) = translateValue v
-- All input variables are bound at this point,
-- so if a variable is not a function and not in the bindings, that's an error
-- so a variable must either be a function name in an application
-- or bound in the bindings
translatePattern (Variable x _) =
do env <- environment
case map snd $ filter ((== x) . fst) (envFunctions env ++ envProperties env) of
[ ] -> do bindings <- ask
return $ bindings x
_ -> error $ "Variable '" ++ x ++ "' is unbound"
do bindings <- ask
return $ bindings x
translatePattern (PConstructor c ps (ADT d)) =
do sps <- mapM translatePattern ps
return $ SCtr d c sps
Expand Down

0 comments on commit 32788c9

Please sign in to comment.