aboutsummaryrefslogtreecommitdiff
path: root/src/Error.hs
blob: 96b02dcb5a8288894e04745b0e2adbe77e4ff438 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)