From d1fc24d2f17ca1649717c76a130db3869b6abc88 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sat, 13 Aug 2022 07:51:47 +0100 Subject: Split in modules --- src/Error.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/Error.hs (limited to 'src/Error.hs') diff --git a/src/Error.hs b/src/Error.hs new file mode 100644 index 0000000..96b02dc --- /dev/null +++ b/src/Error.hs @@ -0,0 +1,16 @@ +module Error where + +import Data.List (sort) +import Text.Parsec (SourcePos) + +data Error = Error String SourcePos deriving (Eq) + +instance Show Error where + show (Error message pos) = + "error: " ++ show pos ++ ":\n" ++ message + +instance Ord Error where + compare (Error _ pos1) (Error _ pos2) = compare pos1 pos2 + +showErrorList :: [Error] -> String +showErrorList errs = unlines $ map show (sort errs) -- cgit v1.2.3