X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=Interpret.hs;fp=Interpret.hs;h=c5ef5e0589a302c44e7ac2436cea97660312c366;hp=8cf3c1b2657270d016c8f28256b993adbd566c96;hb=97719af3b544b9fae80e886bf6a49c51b4a320a9;hpb=3e277a6a62728085cd8ba735b50bdac0b6d68808 diff --git a/Interpret.hs b/Interpret.hs index 8cf3c1b..c5ef5e0 100644 --- a/Interpret.hs +++ b/Interpret.hs @@ -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