aboutsummaryrefslogtreecommitdiff
path: root/src/Error.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-08-13 07:51:47 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-08-13 07:51:47 +0100
commitd1fc24d2f17ca1649717c76a130db3869b6abc88 (patch)
tree3c02146890c46e264ff2e0bca0529750b45b6737 /src/Error.hs
parenta41685b320d9b5e6aa18fc630c3d5e9479195e79 (diff)
downloadmicro-lang-hs-d1fc24d2f17ca1649717c76a130db3869b6abc88.tar.gz
micro-lang-hs-d1fc24d2f17ca1649717c76a130db3869b6abc88.zip
Split in modules
Diffstat (limited to 'src/Error.hs')
-rw-r--r--src/Error.hs16
1 files changed, 16 insertions, 0 deletions
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)