HacWrite certainly seems like an improvement over Haskell.
However, it is just not as good as the scripting languages.
HacWrite still requires the author to differentiate between strings and
other types, still requires explicit use of show and still requires more
typing and curly balancing.  Isn't this nicer?

"insert into mytable values (NULL,'$var1','$(var2+var3)','$var3')

-Alex-


___________________________________________________________________
S. Alexander Jacobson                   Shop.Com
1-212-697-0184 voice                    The Easiest Way To Shop


On Tue, 8 Jun 1999, Magnus Carlsson wrote:

> I've been using a preprocessor to Haskell that I call HacWrite, which
> adds a new kind of string appropriate for entering text.  Such strings
> can span multiple lines and can be escaped using curly brackets:
> 
>   var1 = 2*2
>   var2 = 4*var1
>   var3 = �Foobar�
>   sqlstring = �insert into mytable values
>     (NULL,'{show(var1)}','{show(var2)}','{var3}');�
> 
> Text is enclosed within �these characters� (which are hard to find on
> my keyboard, so I let Emacs insert them when I press '"'). To support
> markup, stuff that follows a space inside an escape is treated as
> text:
> 
>    �This {bf sentence contains words in boldface}.�
> 
> Here, `bf' is a markup function from text to text.
> 
> I've found HacWrite quite useful for document writing (see
> http://www.cs.chalmers.se/~hallgren/Thesis/ for a longer example :-),
> but I'm sure it could be useful for CGI-scripting and the like as
> well. 
> 
> /M
> 
> S. Alexander Jacobson writes:
>  > A popular thing to do with computer languages (especially scripting
>  > languages) is to  manipulate text and insert variables into strings.  
>  > It is extremely irritating to escape in and out of strings via ++ in
>  > Haskell or + in Java/Javascript.  
>  > e.g. 
>  > > var1 = 2*2
>  > > var2 = 4*var1
>  > > var3 = "Foobar""
>  > > sqlstring = "insert into mytable values "++
>  > >  "(NULL,'"++(show var1)++"','"++(show var2)++"','"++var3"');"
>  > 
>  > It would be much nicer if Haskell did what perl,php, and tcl do:
>  > > sqlstring="insert into mytable values (NULL,'$var1','$var2','$var3')".
>  > Even nicer would be:
>  > > sqlstring="insert into mytable values
>  >   (NULL,'$var1','$(var1+var2)','$var3')".
>  > 
>  > (Notice both the embedded evaluation and the fact that the string runs
>  > accross multiple lines)
>  > 
>  > Supporting this feature involves either:
>  > a. a syntactic transformation after you have type information (don't
>  > 'show' strings)
>  > or 
>  > b. redefining show string not to return quotation marks
>  > 
>  > To me the second makes more sense, but either way, this feature would make 
>  > haskell programming much less annoying.
>  > 
>  > 
>  > -Alex-
>  > 
>  > PS Why does show string return quotation marks?  It seems inconsistent.
>  > 
>  > ___________________________________________________________________
>  > S. Alexander Jacobson                      Shop.Com
>  > 1-212-697-0184 voice                       The Easiest Way To Shop
> 





Reply via email to