@@ -34,6 +34,7 @@ import Reporting.Doc ((<+>))
34import qualified Reporting.Doc as D
34import qualified Reporting.Doc as D
35import qualified Reporting.Task as Task
35import qualified Reporting.Task as Task
36import qualified Reporting.Progress.Repl as Repl
36import qualified Reporting.Progress.Repl as Repl
37+import qualified Reporting.Render.Type.Localizer as L
@@ -53,7 +54,7 @@ run () (Flags maybeAlternateInterpreter) =
53 printWelcomeMessage
54 printWelcomeMessage
54 settings <- initSettings
55 settings <- initSettings
55 let manager = Repl.runInputT settings (Repl.withInterrupt loop)
56 let manager = Repl.runInputT settings (Repl.withInterrupt loop)
56− (exitCode,_,_) <- RWS.runRWST manager interpreter initalState
57+ (exitCode,_,_) <- RWS.runRWST manager interpreter initialState
57 Exit.exitWith exitCode
58 Exit.exitWith exitCode
@@ -107,7 +108,7 @@ eval input =
107 return (Just Exit.ExitSuccess)
108 return (Just Exit.ExitSuccess)
110− do RWS.put initalState
111+ do RWS.put initialState
111 report "<reset>"
112 report "<reset>"
113 Help info ->
114 Help info ->
@@ -115,10 +116,14 @@ eval input =
116 Code entry ->
117 Code entry ->
117 Repl.handleInterrupt (report "<cancelled>") $
118 Repl.handleInterrupt (report "<cancelled>") $
118− do state@(State _ imports types defs tricks) <- RWS.get
119+ do state@(State _ imports types defs tricks localizer) <- RWS.get
119 case entry of
120 case entry of
120− Elm.Import name src ->
121+ Elm.Import name alias exposing src ->
121− interpret None $ state { _imports = Map.insert name src imports }
124+ { _imports = Map.insert name src imports
125+ , _localizer = L.replAdd name alias exposing localizer
123 Elm.Type name src ->
128 Elm.Type name src ->
124 interpret None $ state { _types = Map.insert name src types }
129 interpret None $ state { _types = Map.insert name src types }
@@ -217,16 +222,17 @@ data State =
217 , _types :: Map.Map N.Name Text.Text
222 , _types :: Map.Map N.Name Text.Text
218 , _defs :: Map.Map N.Name Text.Text
223 , _defs :: Map.Map N.Name Text.Text
219 , _tricks :: [Text.Text]
224 , _tricks :: [Text.Text]
225+ , _localizer :: L.Localizer
223−initalState :: State
229+initialState :: State
224−initalState =
230+initialState =
225− State 0 Map.empty Map.empty Map.empty []
231+ State 0 Map.empty Map.empty Map.empty [] L.replEmpty
228compile :: Output -> State -> Task.Task (Maybe FilePath)
234compile :: Output -> State -> Task.Task (Maybe FilePath)
229−compile output (State count imports types defs tricks) =
235+compile output (State count imports types defs tricks localizer) =
231 elmSourceCode =
237 elmSourceCode =
232 (<>) "module Elm_Repl exposing (..)\n\n" $
238 (<>) "module Elm_Repl exposing (..)\n\n" $
@@ -236,12 +242,12 @@ compile output (State count imports types defs tricks) =
236 case output of
242 case output of
238 if Map.null types && Map.null defs && null tricks then
244 if Map.null types && Map.null defs && null tricks then
239− evaluate (elmSourceCode <> "unit = ()") Nothing
245+ evaluate localizer (elmSourceCode <> "unit = ()") Nothing
241− evaluate elmSourceCode Nothing
247+ evaluate localizer elmSourceCode Nothing
243 Def name ->
249 Def name ->
244− evaluate elmSourceCode (Just name)
250+ evaluate localizer elmSourceCode (Just name)
246 Expr expr ->
252 Expr expr ->
@@ -249,7 +255,7 @@ compile output (State count imports types defs tricks) =
249 text = Text.replace "\n" "\n " expr
255 text = Text.replace "\n" "\n " expr
250 def = N.toBuilder name <> " =\n " <> Text.encodeUtf8Builder text <> "\n"
256 def = N.toBuilder name <> " =\n " <> Text.encodeUtf8Builder text <> "\n"
252− evaluate (elmSourceCode <> def) (Just name)
258+ evaluate localizer (elmSourceCode <> def) (Just name)
255addLines :: Map.Map N.Name Text.Text -> B.Builder -> B.Builder
261addLines :: Map.Map N.Name Text.Text -> B.Builder -> B.Builder
@@ -257,9 +263,9 @@ addLines dict builder =
257 Map.foldr (\text b -> Text.encodeUtf8Builder text <> "\n" <> b) builder dict
263 Map.foldr (\text b -> Text.encodeUtf8Builder text <> "\n" <> b) builder dict
260−evaluate :: B.Builder -> Maybe N.Name -> Task.Task (Maybe FilePath)
266+evaluate :: L.Localizer -> B.Builder -> Maybe N.Name -> Task.Task (Maybe FilePath)
261−evaluate builder maybeName =
267+evaluate localizer builder maybeName =
262− Project.compileForRepl (LBS.toStrict (B.toLazyByteString builder)) maybeName
268+ Project.compileForRepl localizer (LBS.toStrict (B.toLazyByteString builder)) maybeName
@@ -279,7 +285,7 @@ initSettings =
280lookupCompletions :: String -> Runner [Repl.Completion]
286lookupCompletions :: String -> Runner [Repl.Completion]
281lookupCompletions string =
287lookupCompletions string =
282− do (State _ imports types defs _) <- RWS.get
288+ do (State _ imports types defs _ _) <- RWS.get
284 addMatches string False defs $
290 addMatches string False defs $
285 addMatches string False types $
291 addMatches string False types $