on 33261ec help sign in
elk/src/Reporting/Error.hs
35 lines 887 B 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 report =
25 case err of
26 Syntax syntaxError ->
27 Syntax.toReport syntaxError
29 Canonicalize canonicalizeError ->
30 Canonicalize.toReport canonicalizeError
32 Type typeError ->
33 Type.toReport typeError
34 in
35 Report.toString location region report source