1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Exit.Compile
11import qualified Data.List as List
12import qualified Data.Text as Text
13import qualified Data.Time.Clock as Time
14import qualified Text.PrettyPrint.ANSI.Leijen as P
16import qualified Elm.Compiler as Compiler
17import qualified Elm.Compiler.Module as Module
18import qualified Json.Encode as Encode
29 , _time :: Time.UTCTime
30 , _source :: Text.Text
31 , _errors :: [Compiler.Error]
39toJson :: Exit -> Encode.Value
40toJson (Exit name path _ source errors) =
41 Compiler.errorsToJson name path source errors
48toDoc :: Exit -> [Exit] -> P.Doc
51 (exit, exits) = sortByTime e es
53 P.vcat (toDocHelp exit exits)
56toDocHelp :: Exit -> [Exit] -> [P.Doc]
63 exitToDoc e1 : separator (_name e1) (_name e2) : toDocHelp e2 otherErrors
66exitToDoc :: Exit -> P.Doc
67exitToDoc (Exit _name path _time source errors) =
68 Compiler.errorsToDoc path source errors
71separator :: Module.Raw -> Module.Raw -> P.Doc
72separator beforeName afterName =
74 before = Module.nameToString beforeName ++ " ↑ "
75 after = " ↓ " ++ Module.nameToString afterName
78 [ P.indent (80 - length before) (P.text before)
79 , "====o======================================================================o===="
90sortByTime :: Exit -> [Exit] -> (Exit, [Exit])
91sortByTime exit exits =
92 case List.sortBy timeCompare exits of
97 if _time exit < _time e then
100 (e, List.insertBy timeCompare exit es)
103timeCompare :: Exit -> Exit -> Ordering
105 compare (_time e1) (_time e2)
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