on master help sign in
allow the backslash in the REPL for anyone using books from before
commit0e10baa75a59f6cdcac73d8b0285a792c2302366 authorEvan Czaplicki <evancz@users.noreply.github.com> dateFri 9 Aug 2019, 12:46 (7 years ago) parent8224011
1 file changed+20−3
terminal/src/Repl.hs+20−3
terminal/src/Repl.hs+20−3
@@ -169,9 +169,9 @@ read =
169169 Nothing ->
170170 return Exit
171171
172− Just line ->
172+ Just chars ->
173173 let
174− lines = Lines line []
174+ lines = Lines (stripLegacyBackslash chars) []
175175 in
176176 case categorize lines of
177177 Done input -> return input
@@ -187,13 +187,30 @@ readMore previousLines prefill =
187187
188188 Just chars ->
189189 let
190− lines = addLine chars previousLines
190+ lines = addLine (stripLegacyBackslash chars) previousLines
191191 in
192192 case categorize lines of
193193 Done input -> return input
194194 Continue p -> readMore lines p
195195
196196
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+
197214data Prefill
198215 = Indent
199216 | DefStart N.Name