On Tue, 8 Jun 1999, Paul Hudak wrote:
> I agree that Haskell's string notation could be improved, but note that
> you could write:
>
> > sqlstring1 = "insert into mytable values \
> > \(NULL,'"#var1++"','"#(var1+var2)++"','"++var3++"')"
>
That is arguably even more ugly than just consistently using ++.
It still requires the user to remember which variables contain strings and
which variables contain other things. It then create two operators for
concatenation. ugh.
If I were to go in this direction, I would create a
class whose default implementation is show and a concatenation operator
that detects whether applying show to its arguments results in a quoted
string. Then strip the quotes. Again, synax like:
"'blah','"#var1#"','glah'"
is still ugly but an improvement.
If HaskelL MUST have this type of syntax, then there should be a standard
operator for #. Since # is used as flip($) and in TREX, I don't think it
is an available symbol.
> In particular, note that literal strings can be broken across lines
> using the backslant character, and (of course) "embedded evaluation"
> comes for free.
Again, the backslash character does not help much. Typicall one will do
major editing of these string functions over the course of development.
As you reduce the first line of the string and increasee the second line,
managing these backslashes becomes a real pain. Perl, PHP, and
TCL actually allow pages! long strings. You don't want to do backslash
management on text this long.
I strongly urge you to take a day to do web/database development inn any
of these languages and you will see how much better it can be.
> > PS Why does show string return quotation marks?
> > It seems inconsistent.
>
> show x should be a string that when printed looks like the value that
> you would have to type to generate it directly. This example is most
> instructive:
>
> data Foo = Foo
> deriving Show
>
> show Foo ==> "Foo"
> show (show Foo) ==> show ("Foo") ==> "\"Foo\""
> show (show (show Foo)) ==> show ("\"Foo\"") ==> "\"\\\"Foo\\\"\""
>
> etc. This is actually quite consistent.
Fair enough, but then the function should not be called show. The spec
for show here is an internal serialization format. I guess the right
thing to do here is define eshow which does not quote strings.
-Alex-
___________________________________________________________________
S. Alexander Jacobson Shop.Com
1-212-697-0184 voice The Easiest Way To Shop