From 767e3eedab61adc84888f075651f1c977fad795b Mon Sep 17 00:00:00 2001 From: darkf Date: Wed, 23 Oct 2013 14:43:30 -0700 Subject: [PATCH] evaluate if expressions --- interp.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interp.hs b/interp.hs index 344e556..988c8f6 100644 --- a/interp.hs +++ b/interp.hs @@ -119,6 +119,12 @@ eval (ListConst v) = eval (TupleConst v) = mapM eval v >>= return . TupleV +eval (IfExpr c t e) = eval c >>= \cond -> + case cond of + BoolV True -> eval t + BoolV False -> eval e + _ -> error "if: condition must be a boolean" + eval (Var var) = get >>= \(_,env) -> case lookup env var of Just v -> return v