[Haskell-cafe] Folded long string literals and CPP?
Viktor Dukhovni
ietf-dane at dukhovni.org
Mon Nov 20 20:07:42 UTC 2023
On Mon, Nov 20, 2023 at 02:47:39PM -0500, Viktor Dukhovni wrote:
> It looks like there's some sort of syntax conflict between CPP and
> long string literals folded across multiple lines. Is there a
> way to have both CPP and folded long string literals?
>
I may have found an acceptable work-around:
{-# LANGUAGE CPP #-}
module Main(main) where
hello :: String
hello = "Hello\ \
\ World!"
main :: IO ()
main = print hello
Is this trick "well known"? CPP turns the above into:
{-# LANGUAGE CPP #-}
module Main(main) where
hello :: String
hello = "Hello\ \ World!"
main :: IO ()
main = print hello
which is then valid Haskell syntax and yields the right value.
--
Viktor.
More information about the Haskell-Cafe
mailing list