A tiny change to Haskell, borrowed from Erlang, would solve the problem, I think, with an increase in readability. In Erlang, "c1...cn" ++ Pattern is a pattern, equivalent (in Haskell terms) to ('c1' :: 'c2' :: ... 'cn' :: Pattern). This means that a long string can be written as ("..." ++ "..." ++ ... ++ "..."), spread across as many lines as you need, with each substring being complete on a line, in any context you want. In an expression context, you can already do this, and that is easier to read than strings broken across multiple lines. It makes the treatment of leading white space completely obvious (if it's inside string quotes, it's part of the text, if not, it's not). The only problem is that you cannot use that construction where a pattern is needed (although if you are trying to use a long string as a pattern I have to wonder why). So the tiny extension is to allow an explicit concatenation of string literals as a string literal in a pattern. Right now, hello :: String hello = "Hello\ \ \ World!" can and should be written hello :: String hello = "Hello " ++ "World!" On Tue, 21 Nov 2023 at 23:53, Viktor Dukhovni <ietf-dane@dukhovni.org> wrote:
On Tue, Nov 21, 2023 at 09:27:12AM +0000, Dan Dart wrote:
That does sound like a bug. but it doesn't seem patchable using {-# LANGUAGE CPP #-} because it *is* a bug in -XCPP... :p
Have you reported it anywhere?
Not yet reported outside this thread. Sure, morally speaking, this is a bug in "-XCPP", but in practice "-XCPP" unavoidably uses the actual C preprocessor, and is subject to its syntax idiosyncrasies.
There's not a lot GHC can do once CPP joins the split lines and drops the trailing "\", and the documented trailing whitespace work-around no longer (if it once did) helps.
So the only options appear to be to live with editing the code to to use a trailing "\ \" instead of just "\" when enablng -XCPP (and reverting when dropping "-XCPP", or else introduce a new syntax for multi-part string literals.
Unless someone can suggest a better idea...
-- Viktor. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.