On Wed, 22 Jul 1998, Simon L Peyton Jones wrote:
> Let me advertise Olivier Danvy's very cunning idea to implement
> printf in Haskell/ML.
>
> http://www.brics.dk/RS/98/5/index.html
Printf isn't really what I want, but I am happy to take a look.
I am really looking for a my scripting like solution -- ideally one that
allows me to embed Haskell expressions directly in strings the way TCL
does. The overhead of "foo"./expr./"bar" as opposed to "foo $expr$ bar"
is not large, but it is not small either. The most ideal case would be
"foo" expr "bar" -- which is distinct from "foo" `expr` "bar". I suppose
existential types will allow a variant using the (,) operator e.g.
["foo",expr,"bar"] where expr is an instance of Stringable (or Show).
> There's no technical issue here. One could relax the defaulting
> restriction, at the cost of (perhaps) sometimes unexpected behaviour.
> Or, as you show, you can just tell it which type to use:
>
> res = (2+2)::Int ./ "hello"
Well, I was actually hoping that there was a way to tell Haskell to treat
all numeric literals as Float and force the programmer to do conversions
where desired. Having Haskell guess the type gets you back into the
automatic type conversion discussion from last week that I don't think
ever got resolved. In other words, why should the prelude have different
semantics for numeric literals than the rest of the language?
-Alex-
___________________________________________________________________
S. Alexander Jacobson i2x Media
1-212-697-0184 voice 1-212-697-1427 fax