on 54df18a help sign in
elk/src/Reporting/Error.hs
41 lines 1.0 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.Report as Report
11-- ALL POSSIBLE ERRORS
13data Error
14 = Syntax Syntax.Error
15 | Canonicalize Canonicalize.Error
16 | Type Type.Error
19-- TO STRING
21toString :: String -> String -> A.Located Error -> String
22toString location source (A.A region err) =
23 let
24 (tag, report) =
25 case err of
26 Syntax syntaxError ->
27 ( "SYNTAX ERROR"
28 , Syntax.toReport syntaxError
29 )
31 Canonicalize canonicalizeError ->
32 ( "NAMING ERROR"
33 , Canonicalize.toReport canonicalizeError
34 )
36 Type typeError ->
37 ( "TYPE ERROR"
38 , Type.toReport typeError
39 )
40 in
41 Report.toString tag location region report source