]> git.rmz.io Git - my-scheme.git/commitdiff
Use `showVal` to print with show rather than the default master
authorSamir Benmendil <me@rmz.io>
Tue, 23 Jan 2018 22:49:41 +0000 (22:49 +0000)
committerSamir Benmendil <me@rmz.io>
Tue, 23 Jan 2018 22:49:41 +0000 (22:49 +0000)
Inject `showVal` as the `show` member of an instance of `Show LispVal`.

app/Main.hs

index 996f9211119591408d07062b610928ba5d5dddff..78f37ea4132604b9ee481dba40f65ab0e5738be3 100644 (file)
@@ -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 ++ ")"