on master help sign in
allow the backslash in the REPL for anyone using books from before
0e10baaEvan Czaplicki
terminal/src/Repl.hs+20−3
@@ -169,9 +169,9 @@ read =
169 Nothing ->
169 Nothing ->
170 return Exit
170 return Exit
171
171
172− Just line ->
172+ Just chars ->
173 let
173 let
174− lines = Lines line []
174+ lines = Lines (stripLegacyBackslash chars) []
175 in
175 in
176 case categorize lines of
176 case categorize lines of
177 Done input -> return input
177 Done input -> return input
@@ -187,13 +187,30 @@ readMore previousLines prefill =
187
187
188 Just chars ->
188 Just chars ->
189 let
189 let
190− lines = addLine chars previousLines
190+ lines = addLine (stripLegacyBackslash chars) previousLines
191 in
191 in
192 case categorize lines of
192 case categorize lines of
193 Done input -> return input
193 Done input -> return input
194 Continue p -> readMore lines p
194 Continue p -> readMore lines p
195
195
196
196
197+-- For compatibility with 0.19.0 such that readers of "Programming Elm" by @jfairbank
198+-- can get through the REPL section successfully.
199+--
200+-- TODO: remove stripLegacyBackslash in next MAJOR release
201+--
202+stripLegacyBackslash :: [Char] -> [Char]
203+stripLegacyBackslash chars =
204+ case chars of
205+ [] ->
206+ []
207+
208+ _:_ ->
209+ if last chars == '\\'
210+ then init chars
211+ else chars
212+
213+
197data Prefill
214data Prefill
198 = Indent
215 = Indent
199 | DefStart N.Name
216 | DefStart N.Name