[Haskell] ANNOUNCE: string-qq-0.0.2
Ivan Lazar Miljenovic
ivan.miljenovic at gmail.com
Tue Jun 28 11:09:08 CEST 2011
2011/6/28 Jean-Marie Gaillourdet <jmg at gaillourdet.net>:
> Hi Audrey,
>
> are you aware that Haskell already supports multi-line strings?
>
> foo = "This is a\
> \multi-line\
> \string!"
>
> See Section 2.6 of http://haskell.org/onlinereport/lexemes.html
I've used this approach for multi-line strings; note first of all that
to make the examples equivalent you would need to add '\n' twice to
your definition of foo. However, even without that it's rather
annoying to use and can be difficult to typeset correctly (though that
admittedly could be due to the indentation support in haskell-mode not
being up to par as it refuses to indent subsequent lines properly
after the String).
Another alternative would be:
foo = unlines
[ "This is a"
, "multi-line"
, "string!"
]
Though it too can be a bit cumbersome.
>
> Regards,
> Jean
>
> On 25.06.11 22:55, 唐鳳 wrote:
>> Hi all,
>>
>> I've just released string-qq 0.0.2 to Hackage:
>>
>> http://hackage.haskell.org/package/string-qq
>>
>> The main interface is the "s" quasi-quoter:
>>
>> foo :: IsString a => a
>> foo = [s|
>> This is a
>> multi-line
>> string!
>> |]
>>
>> It allows simple multi-line strings of any IsString type (Text, String, ByteString, etc),
>> with no interpolation at all, except that the leading newline is trimmed and
>> "\r\n" sequences are converted to "\n".
>>
>> It's compatible with both GHC6 and GHC7; for GHC6, write [$s|…|] instead of [s|…|].
>>
>> Suggestions and feedback are most welcome. :-)
>>
>> Cheers,
>> Audrey
>>
>> _______________________________________________
>> Haskell mailing list
>> Haskell at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell
>
>
> --
> Jean-Marie Gaillourdet
>
> blog: gaillourdet.net
> {email, xmpp, jabber, ichat, gimix, gtalk}: jmg at gaillourdet.net
>
> _______________________________________________
> Haskell mailing list
> Haskell at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>
--
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com
More information about the Haskell
mailing list