on 1b95db0 help sign in
elk/src/Reporting/Error.hs
43 lines 1.1 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2module Reporting.Error where
4import qualified Reporting.Annotation as A
5import qualified Reporting.Error.Canonicalize as Canonicalize
6import qualified Reporting.Error.Syntax as Syntax
7import qualified Reporting.Error.Type as Type
8import qualified Reporting.Error.CheckMatch as CheckMatch
9import qualified Reporting.Report as Report
12-- ALL POSSIBLE ERRORS
14data Error
15 = Syntax Syntax.Error
16 | Canonicalize Canonicalize.Error
17 | Type Type.Error
18 | CheckMatch CheckMatch.Error
21-- TO STRING
23toString :: String -> String -> A.Located Error -> String
24toString location source (A.A region err) =
25 let
26 (tag, report) =
27 case err of
28 Syntax syntaxError ->
29 ( "SYNTAX ERROR"
30 , Syntax.toReport syntaxError
31 )
33 Canonicalize canonicalizeError ->
34 ( "NAMING ERROR"
35 , Canonicalize.toReport canonicalizeError
36 )
38 Type typeError ->
39 ( "TYPE ERROR"
40 , Type.toReport typeError
41 )
42 in
43 Report.toString tag location region report source