@@ -14,7 +14,7 @@ eval (List [Atom "if", pred, conseq, alt]) =
1414 case result of
1515 Bool False -> eval alt
1616 Bool True -> eval conseq
17- _ -> throwError $ TypeMismatch " Bool" $ checkType pred
17+ _ -> throwError $ TypeMismatch " Bool" pred
1818eval (List (Atom func : args)) = mapM eval args >>= apply func
1919eval form@ (List (Atom " cond" : clauses)) =
2020 if null clauses
@@ -34,7 +34,7 @@ eval form@(List (Atom "case" : key : clauses)) =
3434 List ((List datums) : exprs) -> do
3535 result <- eval key
3636 equality <- mapM (\ x -> eqv [result, x]) datums
37- if Boolean True `elem` equality
37+ if Bool True `elem` equality
3838 then mapM eval exprs >>= return . last
3939 else eval $ List (Atom " case" : key : tail clauses)
4040 _ -> throwError $ BadSpecialForm " ill-formed case expression: " form
@@ -100,10 +100,10 @@ unpackNum :: LispVal -> ThrowsError Integer
100100unpackNum (Number n) = return n
101101unpackNum (String n) = let parsed = reads n :: [(Integer , String )] in
102102 if null parsed
103- then throwError $ TypeMismatch " number " $ String n
103+ then throwError $ TypeMismatch " Number " $ String n
104104 else return $ fst $ parsed !! 0
105105unpackNum (List [n]) = unpackNum n
106- unpackNum notNum = throwError $ TypeMismatch " number " notNum
106+ unpackNum notNum = throwError $ TypeMismatch " Number " notNum
107107
108108symbolp, integerp, floatp, ratiop, complexp, stringp, boolp, listp, vectorp
109109 :: LispVal -> LispVal
@@ -143,11 +143,11 @@ unpackStr :: LispVal -> ThrowsError String
143143unpackStr (String s) = return s
144144unpackStr (Number s) = return $ show s
145145unpackStr (Bool s) = return $ show s
146- unpackStr notString = throwError $ TypeMismatch " String" $ checkType notString
146+ unpackStr notString = throwError $ TypeMismatch " String" notString
147147
148148unpackBool :: LispVal -> ThrowsError Bool
149149unpackBool (Bool b) = return b
150- unpackBool notBool = throwError $ TypeMismatch " Bool" $ checkType notBool
150+ unpackBool notBool = throwError $ TypeMismatch " Bool" notBool
151151
152152symbol2string , string2symbol :: LispVal -> LispVal
153153symbol2string (Atom s) = String s
@@ -158,14 +158,14 @@ string2symbol _ = Atom ""
158158car :: [LispVal ] -> ThrowsError LispVal
159159car [List (x : _)] = return x
160160car [DottedList (x : _) _] = return x
161- car [badArg] = throwError $ TypeMismatch " Pair" $ checkType badArg
161+ car [badArg] = throwError $ TypeMismatch " Pair" badArg
162162car badArgList = throwError $ NumArgs 1 badArgList
163163
164164cdr :: [LispVal ] -> ThrowsError LispVal
165165cdr [List (_ : xs)] = return $ List xs
166166cdr [DottedList [_] x] = return x
167167cdr [DottedList (_ : xs) x] = return $ DottedList xs x
168- cdr [badArg] = throwError $ TypeMismatch " Pair" $ checkType badArg
168+ cdr [badArg] = throwError $ TypeMismatch " Pair" badArg
169169cdr badArgList = throwError $ NumArgs 1 badArgList
170170
171171cons :: [LispVal ] -> ThrowsError LispVal
@@ -216,14 +216,14 @@ equal badArgList = throwError $ NumArgs 2 badArgList
216216
217217stringLen :: [LispVal ] -> ThrowsError LispVal
218218stringLen [(String s)] = Right $ Number $ fromIntegral $ length s
219- stringLen [notString] = throwError $ TypeMismatch " String" $ checkType notString
219+ stringLen [notString] = throwError $ TypeMismatch " String" notString
220220stringLen badArgList = throwError $ NumArgs 1 badArgList
221221
222222stringRef :: [LispVal ] -> ThrowsError LispVal
223223stringRef [(String s), (Number k)]
224224 | length s < k' + 1 = throwError $ Default " Out of bound error"
225225 | otherwise = Right $ String $ [s !! k']
226226 where k' = fromIntegral k
227- stringRef [(String s), notNum] = throwError $ TypeMismatch " Number" $ checkType notNum
228- stringRef [notString, _] = throwError $ TypeMismatch " String" $ checkType notString
227+ stringRef [(String s), notNum] = throwError $ TypeMismatch " Number" notNum
228+ stringRef [notString, _] = throwError $ TypeMismatch " String" notString
229229stringRef badArgList = throwError $ NumArgs 2 badArgList
0 commit comments