]> git.rmz.io Git - my-scheme.git/blobdiff - app/Main.hs
Show values for Lists
[my-scheme.git] / app / Main.hs
index 1495605d09602a2ed23717d3b5956402874a6ef4..996f9211119591408d07062b610928ba5d5dddff 100644 (file)
@@ -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