9import Control.Concurrent (forkIO)
10import Control.Concurrent.MVar (newEmptyMVar, putMVar, readMVar)
11import Control.Monad (foldM, void)
12import Control.Monad.Except (liftIO)
13import qualified Data.Binary as Binary
15import qualified Data.Map as Map
16import qualified Data.Maybe as Maybe
17import qualified Data.Text.Encoding as Text
19import qualified Elm.Compiler as Compiler
20import qualified Elm.Compiler.Module as Module
21import qualified Elm.Docs as Docs
22import qualified Json.Encode as Encode
24import File.Compile (Answer(..))
25import qualified Reporting.Exit.Compile as E
26import qualified Reporting.Exit as Exit
27import qualified Reporting.Task as Task
28import qualified Stuff.Paths as Path
35ignore :: Map Module.Raw Answer -> Task.Task (Map Module.Raw Compiler.Artifacts)
38 ignorer _name result =
41 gather ignorer answers
48write :: FilePath -> Map Module.Raw Answer -> Task.Task (Map Module.Raw Compiler.Artifacts)
51 writer name result@(Compiler.Artifacts elmi elmo _) =
52 do mvar <- newEmptyMVar
54 do Binary.encodeFile (Path.elmi root name) elmi
55 Binary.encodeFile (Path.elmo root name) elmo
59 do mvars <- gather writer answers
60 liftIO $ traverse readMVar mvars
63writeDocs :: Map Module.Raw Compiler.Artifacts -> FilePath -> Task.Task Docs.Documentation
64writeDocs results path =
66 getDocs (Compiler.Artifacts _ _ docs) =
69 case Maybe.mapMaybe getDocs (Map.elems results) of
74 do liftIO $ Encode.writeUgly path $ Encode.list Docs.encode docs
75 return $ Docs.toDict docs
82gather :: OnGood a -> Map Module.Raw Answer -> Task.Task (Map Module.Raw a)
83gather onGood answers =
84 do summary <- liftIO $
85 foldM (gatherHelp onGood) (Right Map.empty) (Map.toList answers)
89 Task.throw (Exit.Compile err errors)
95type OnGood a = Module.Raw -> Compiler.Artifacts -> IO a
98gatherHelp :: OnGood a -> Summary a -> (Module.Raw, Answer) -> IO (Summary a)
99gatherHelp onGood summary (name, answer) =
104 Bad path time src errors ->
105 do let err = E.Exit name path time (Text.decodeUtf8 src) errors
106 return (addErr err summary)
109 do value <- onGood name result
110 return (addOk name value summary)
118 Either (E.Exit, [E.Exit]) (Map Module.Raw a)
121addOk :: Module.Raw -> a -> Summary a -> Summary a
122addOk name result acc =
128 Right (Map.insert name result results)
131addErr :: E.Exit -> Summary a -> Summary a
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