diff --git a/src/BC/Eval.hs b/src/BC/Eval.hs index aab993b..1d82092 100644 --- a/src/BC/Eval.hs +++ b/src/BC/Eval.hs @@ -135,7 +135,12 @@ funCall state (BFun name args body) provided = callWith state (a:args) (p:provided) = let (evald, nstate) = eval state p in callWith (M.insert a evald nstate) args provided --- TODO: fix state forgetfulness funCall state (BNative body) provided = - let args = map (fst . (eval state)) provided + let (args, nstate) = callWith state provided in (body args, state) +-- TODO: make tail recursive with accumulator + where callWith state [] = (state, []) + callWith state (x:xs) = + let (evald, nstate) = eval state x + (retstate, l) = callWith nstate xs + in (retstate, evald:l)