]> ruin.nu Git - proglang.git/blobdiff - Interpret.hs
most of the semantics added
[proglang.git] / Interpret.hs
index 8cf3c1b2657270d016c8f28256b993adbd566c96..c5ef5e0589a302c44e7ac2436cea97660312c366 100644 (file)
@@ -14,10 +14,6 @@ instance Show Value where
 
 type Variables = [Map Ident Value]
 
-inList :: Eq a => a -> [a] -> Bool
-inList _ [] = False
-inList a (x:xs) = if a == x then True else inList a xs
-
 --eval :: (MonadState Variables m) => Exp -> m Value
 eval :: Exp -> StateT Variables IO Value
 eval (EBool b) = return (VBool b)
@@ -27,7 +23,7 @@ eval (EAss i e) = setVariableValue i e
 eval (BiOpExp e o e') = do
        v <- eval e
        v'<- eval e'
-       if inList o [Eq,NEq] then return $ opE o v v'
+       if elem o [Eq,NEq] then return $ opE o v v'
                else let (VInt n1) = v in let (VInt n2) = v' in return $ op o n1 n2
 eval (EPost i o) = do
        (VInt n) <- getVariableValue i
@@ -49,7 +45,7 @@ eval EReadB = do
 getWord :: IO String
 getWord =  do
        c <- getChar
-       if inList c [' ', '\n', '\t', '\r']
+       if elem c [' ', '\n', '\t', '\r']
                then return ""
                else do
                        l <- getWord