From 8641ce3e1a730c8195e5a74fabef8814f43b05f8 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 13 Oct 2020 18:07:08 +0530 Subject: refactor Error into submodules --- src/Error.hs | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 src/Error.hs (limited to 'src/Error.hs') diff --git a/src/Error.hs b/src/Error.hs deleted file mode 100644 index bfc8d14..0000000 --- a/src/Error.hs +++ /dev/null @@ -1,31 +0,0 @@ -module Error ( - LispError (..) - , LispResult (..) - , unwrap - ) where - -import Control.Monad.Except -import Parser -import Text.ParserCombinators.Parsec - -data LispError = Parse ParseError - | BadForm String Expr - | ArgCount Int [Expr] - | UnknownFunction String - | TypeMismatch String Expr - -unwordsList :: [Expr] -> String -unwordsList = unwords . map show - -instance Show LispError where - show (Parse e) = "Parser Error: " ++ show e - show (BadForm s expr) = "Bad Form: " ++ s ++ ": " ++ show expr - show (ArgCount n es) = "Invalid arity, expected " ++ show n ++ ", got value(s): " ++ unwordsList es - show (UnknownFunction fn) = "Cannot apply function: " ++ fn - show (TypeMismatch msg got) = "Type mismatch, expected " ++ msg ++ ", got: " ++ show got - -type LispResult = Either LispError - -unwrap :: LispResult t -> t -unwrap (Right v) = v -unwrap (Left _) = undefined -- should panic -- cgit v1.2.3