1{-# LANGUAGE OverloadedStrings #-}
3 ( Compile.Artifacts(..)
13import qualified Data.ByteString as BS
14import qualified Data.Map as Map
15import qualified Data.Name as Name
16import qualified Data.Utf8 as Utf8
18import qualified Compile
19import qualified Elm.Interface as I
20import qualified Elm.ModuleName as ModuleName
21import qualified Elm.Package as Pkg
22import qualified Json.Encode as E
23import Json.Encode ((==>))
24import qualified Reporting.Annotation as A
25import qualified Reporting.Doc as D
26import qualified Reporting.Error as Error
27import qualified Reporting.Render.Code as Code
28import qualified Reporting.Report as Report
29import qualified Reporting.Result as Result
30import qualified Reporting.Warning as Warning
39 -> Map.Map ModuleName.Raw ModuleName.Canonical
42 -> ( [Warning.Warning], Either [Error.Error] Compile.Artifacts )
43compile pkg importDict interfaces source =
44 Result.run $ Compile.compile pkg importDict interfaces source
51errorsToDoc :: FilePath -> String -> [Error.Error] -> D.Doc
52errorsToDoc filePath source errors =
55 concatMap (Error.toReports (Code.toSource source)) errors
57 D.vcat $ map (Report.toDoc filePath) reports
64errorsToJson :: ModuleName.Raw -> FilePath -> String -> [Error.Error] -> E.Value
65errorsToJson moduleName filePath source errors =
68 concatMap (Error.toReports (Code.toSource source)) errors
71 [ "path" ==> E.string (Utf8.fromChars filePath)
72 , "name" ==> E.string (Name.toUtf8 moduleName)
73 , "problems" ==> E.array (map reportToJson reports)
77reportToJson :: Report.Report -> E.Value
78reportToJson (Report.Report title region _sgstns message) =
80 [ "title" ==> E.string (Utf8.fromChars title)
81 , "region" ==> encodeRegion region
82 , "message" ==> D.encode message
86encodeRegion :: A.Region -> E.Value
87encodeRegion (A.Region (A.Position sr sc) (A.Position er ec)) =
91 [ ("line", E.int (fromIntegral sr))
92 , ("column", E.int (fromIntegral sc))
96 [ ("line", E.int (fromIntegral er))
97 , ("column", E.int (fromIntegral ec))
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