X-Git-Url: https://git.rmz.io/my-scheme.git/blobdiff_plain/fabc3d8bdaef310b2f18bc53735ad7ee53518822..200ca1efa940b94af2099828c36d6580addb6de9:/app/Main.hs diff --git a/app/Main.hs b/app/Main.hs index 1495605..996f921 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -98,12 +98,17 @@ readExpr input = case parse parseExpr "lisp" input of showVal :: LispVal -> String showVal (Atom atom) = atom +showVal (List list) = "(" ++ unwordsList list ++ ")" +showVal (DottedList head tail) = "(" ++ unwordsList head ++ " . " ++ showVal tail ++ ")" showVal (Number n) = show n showVal (String str) = "\"" ++ str ++ "\"" showVal (Character c) = "'" ++ [c] ++ "'" showVal (Bool True) = "#t" showVal (Bool False) = "#f" +unwordsList :: [LispVal] -> String +unwordsList = unwords . map showVal + main :: IO () main = do args <- getLine