Use environment in evaluation of function definitions
This commit is contained in:
parent
edd12bbbbd
commit
6a8ae208b4
|
@ -234,7 +234,10 @@ evalExpr = cata phi
|
|||
-- environment, but rather should recursively view their own arg
|
||||
-- set
|
||||
args <- traverse ($ env) a
|
||||
return $ Fix $ NVFunction args b
|
||||
-- The body of a function first looks into the arguments, then into the
|
||||
-- env in the evaluation point.
|
||||
let function x = b (x `Map.union` env)
|
||||
return $ Fix $ NVFunction args function
|
||||
|
||||
evalString :: Monad m
|
||||
=> ValueSet m -> NString (ValueSet m -> m (NValue m)) -> m (NValue m)
|
||||
|
|
|
@ -33,6 +33,9 @@ case_function_set_two_arg = constantEqualStr "2" "({ a, b ? 3 }: b - a) { a = 1;
|
|||
-- case_function_set_two_arg_default_scope :: Assertion
|
||||
-- case_function_set_two_arg_default_scope = constantEqualStr "2" "({ a, b ? a * 3 }: b - a) { a = 1; }"
|
||||
|
||||
case_function_definition_uses_environment :: Assertion
|
||||
case_function_definition_uses_environment = constantEqualStr "3" "let f = (let a=1; in x: x+a); in f 2"
|
||||
|
||||
tests :: TestTree
|
||||
tests = $testGroupGenerator
|
||||
|
||||
|
|
Loading…
Reference in a new issue