From: Samir Benmendil Date: Tue, 23 Jan 2018 22:49:41 +0000 (+0000) Subject: Use `showVal` to print with show rather than the default X-Git-Url: https://git.rmz.io/my-scheme.git/commitdiff_plain/0bc46ede3abc3213bbfbe13964a343854e9b89c9 Use `showVal` to print with show rather than the default Inject `showVal` as the `show` member of an instance of `Show LispVal`. --- diff --git a/app/Main.hs b/app/Main.hs index 996f921..78f37ea 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -11,7 +11,6 @@ data LispVal = Atom String | String String | Character Char | Bool Bool - deriving Show symbol :: Parser Char symbol = oneOf "!#$%&|*+-/:<=>?@^_~" @@ -96,6 +95,7 @@ readExpr input = case parse parseExpr "lisp" input of Left err -> "No match: " ++ show err Right val -> "Found value: " ++ showVal val +instance Show LispVal where show = showVal showVal :: LispVal -> String showVal (Atom atom) = atom showVal (List list) = "(" ++ unwordsList list ++ ")"