Re: [Haskell-cafe] multiline strings in haskell?

Yes, just like that ;-) Thanks! Now if somebody has a string interpolation library, I'd be a pretty happy camper ;-) Mike
mvanier:
Is there any support for multi-line string literals in Haskell? I've done a web search and come up empty. I'm thinking of using Haskell to generate web pages and having multi-line strings would be very useful.
Do you mean like this:
string = " line one\n\ \ line two is here\n\ \ line three is this line\n"
$ echo 'putStr string' | ghci A.hs line one line two is here line three is this line
-- Don

Oh, like this (by Stefan Wehr): http://www.cse.unsw.edu.au/~dons/code/icfp05/tests/unit-tests/VariableExpans... $ ghci -fth VariableExpansion.hs *VariableExpansion> let x = 7 in $( expand "${x}" ) "7" *VariableExpansion> let url = "http://www.google.com" *VariableExpansion> $( expand "Here is my url: ${url}. Do you like it?" ) "Here is my url: \"http://www.google.com\". Do you like it?" Cheers, Don mvanier:
Yes, just like that ;-) Thanks!
Now if somebody has a string interpolation library, I'd be a pretty happy camper ;-)
Mike
mvanier:
Is there any support for multi-line string literals in Haskell? I've done a web search and come up empty. I'm thinking of using Haskell to generate web pages and having multi-line strings would be very useful.
Do you mean like this:
string = " line one\n\ \ line two is here\n\ \ line three is this line\n"
$ echo 'putStr string' | ghci A.hs line one line two is here line three is this line
-- Don
Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Excellent! Thanks. Mike Donald Bruce Stewart wrote:
Oh, like this (by Stefan Wehr): http://www.cse.unsw.edu.au/~dons/code/icfp05/tests/unit-tests/VariableExpans...
$ ghci -fth VariableExpansion.hs *VariableExpansion> let x = 7 in $( expand "${x}" ) "7" *VariableExpansion> let url = "http://www.google.com" *VariableExpansion> $( expand "Here is my url: ${url}. Do you like it?" ) "Here is my url: \"http://www.google.com\". Do you like it?"
Cheers, Don
mvanier:
Yes, just like that ;-) Thanks!
Now if somebody has a string interpolation library, I'd be a pretty happy camper ;-)
Mike
mvanier:
Is there any support for multi-line string literals in Haskell? I've done a web search and come up empty. I'm thinking of using Haskell to generate web pages and having multi-line strings would be very useful. Do you mean like this:
string = " line one\n\ \ line two is here\n\ \ line three is this line\n"
$ echo 'putStr string' | ghci A.hs line one line two is here line three is this line
-- Don
Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
dons@cse.unsw.edu.au
-
Michael Vanier