1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Error where
5import Data.Aeson ((.=))
6import qualified Data.Aeson as Json
7import qualified Data.Aeson.Types as Json
9import qualified Reporting.Annotation as A
10import qualified Reporting.Error.Canonicalize as Canonicalize
11import qualified Reporting.Error.Syntax as Syntax
12import qualified Reporting.Error.Type as Type
13import qualified Reporting.Region as Region
14import qualified Reporting.Report as Report
21 | Canonicalize Canonicalize.Error
27toString :: String -> String -> A.Located Error -> String
28toString location source (A.A region err) =
33 Syntax.toReport syntaxError
35 Canonicalize canonicalizeError ->
36 Canonicalize.toReport canonicalizeError
39 Type.toReport typeError
41 Report.toString location region report source
46toJson :: String -> A.Located Error -> Json.Value
47toJson location (A.A region err) =
49 (maybeRegion, additionalFields) =
52 reportToJson [] (Syntax.toReport syntaxError)
54 Canonicalize canonicalizeError ->
58 (\s -> ["suggestions" .= s])
59 (Canonicalize.extractSuggestions canonicalizeError)
61 reportToJson suggestions (Canonicalize.toReport canonicalizeError)
64 reportToJson [] (Type.toReport typeError)
68 , "region" .= maybe region id maybeRegion
69 , "type" .= ("error" :: String)
77 -> (Maybe Region.Region, [Json.Pair])
78reportToJson extraFields (Report.Report title subregion pre post) =
86 (subregion, fields ++ extraFields)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list