@@ -44,22 +44,23 @@ import qualified Reporting.Render.Type.Localizer as L
4444data Flags =
4545 Flags
4646 { _interpreter :: Maybe FilePath
47+ , _noColors :: Bool
4748 }
4849
4950
5051run :: () -> Flags -> IO ()
51−run () (Flags maybeAlternateInterpreter) =
52+run () (Flags maybeAlternateInterpreter noColors) =
5253 do interpreter <- getInterpreter maybeAlternateInterpreter
5354 _ <- Project.getRootWithReplFallback
5455 printWelcomeMessage
5556 settings <- initSettings
5657 let manager = Repl.runInputT settings (Repl.withInterrupt loop)
57− (exitCode,_,_) <- RWS.runRWST manager interpreter initialState
58+ (exitCode,_,_) <- RWS.runRWST manager (interpreter, noColors) initialState
5859 Exit.exitWith exitCode
5960
6061
6162type Runner =
62− RWS.RWST FilePath () State IO
63+ RWS.RWST (FilePath, Bool) () State IO
6364
6465
6566
@@ -155,7 +156,8 @@ data Output = None | Def N.Name | Expr Text.Text
155156
156157interpret :: Output -> State -> Runner (Maybe a)
157158interpret def state =
158− do result <- liftIO $ Task.try Repl.reporter $ compile def state
159+ do noColors <- RWS.asks snd
160+ result <- liftIO $ Task.try Repl.reporter $ compile noColors def state
159161
160162 case result of
161163 Nothing ->
@@ -170,7 +172,7 @@ interpret def state =
170172
171173interpretHelp :: FilePath -> Runner ()
172174interpretHelp path =
173− do interpreter <- RWS.ask
175+ do interpreter <- RWS.asks fst
174176 let proc = (Proc.proc interpreter [path]) { Proc.std_in = Proc.CreatePipe }
175177 liftIO $ Proc.withCreateProcess proc $ \_ _ _ handle ->
176178 do _ <- Proc.waitForProcess handle
@@ -231,8 +233,8 @@ initialState =
231233 State 0 Map.empty Map.empty Map.empty [] L.replEmpty
232234
233235
234−compile :: Output -> State -> Task.Task (Maybe FilePath)
235−compile output (State count imports types defs tricks localizer) =
236+compile :: Bool -> Output -> State -> Task.Task (Maybe FilePath)
237+compile noColors output (State count imports types defs tricks localizer) =
236238 let
237239 header =
238240 "module " <> N.toBuilder N.replModule <> " exposing (..)\n\n"
@@ -241,24 +243,27 @@ compile output (State count imports types defs tricks localizer) =
241243 (<>) header $
242244 addLines imports $ addLines types $ addLines defs $
243245 List.foldr (<>) mempty (map Text.encodeUtf8Builder tricks)
246+
247+ compileForRepl builder maybeName =
248+ Project.compileForRepl noColors localizer (LBS.toStrict (B.toLazyByteString builder)) maybeName
244249 in
245− case output of
246− None ->
247− if Map.null types && Map.null defs && null tricks then
248− evaluate localizer (elmSourceCode <> "unit = ()") Nothing
249− else
250− evaluate localizer elmSourceCode Nothing
250+ case output of
251+ None ->
252+ if Map.null types && Map.null defs && null tricks then
253+ compileForRepl (elmSourceCode <> "unit = ()") Nothing
254+ else
255+ compileForRepl elmSourceCode Nothing
251256
252− Def name ->
253− evaluate localizer elmSourceCode (Just name)
257+ Def name ->
258+ compileForRepl elmSourceCode (Just name)
254259
255− Expr expr ->
256− let
257− name = N.addIndex "repl_value_" count
258− text = Text.replace "\n" "\n " expr
259− def = N.toBuilder name <> " =\n " <> Text.encodeUtf8Builder text <> "\n"
260− in
261− evaluate localizer (elmSourceCode <> def) (Just name)
260+ Expr expr ->
261+ let
262+ name = N.addIndex "repl_value_" count
263+ text = Text.replace "\n" "\n " expr
264+ def = N.toBuilder name <> " =\n " <> Text.encodeUtf8Builder text <> "\n"
265+ in
266+ compileForRepl (elmSourceCode <> def) (Just name)
262267
263268
264269addLines :: Map.Map N.Name Text.Text -> B.Builder -> B.Builder
@@ -266,11 +271,6 @@ addLines dict builder =
266271 Map.foldr (\text b -> Text.encodeUtf8Builder text <> "\n" <> b) builder dict
267272
268273
269−evaluate :: L.Localizer -> B.Builder -> Maybe N.Name -> Task.Task (Maybe FilePath)
270−evaluate localizer builder maybeName =
271− Project.compileForRepl localizer (LBS.toStrict (B.toLazyByteString builder)) maybeName
272−
273−
274274
275275-- SETTINGS
276276