the python string notation (str % tuple) would fit really well too...
putStrLn "hello %s, you got %d right" % ("oliver", 5)

Might be nice.

What would be the type of putStrLn then?

The type of putStrLn would remain unchanged.

The idea would be to let the compiler translate the string
"hello %s, you got %d right"
into the function
(\ (p1, p2) -> "hello " ++ p1 ++ ", you got " ++ show p2 ++ " right")
so that the type system can do its work. Then the % above is only an
application.
There is of course no need for the tuple; a curried function would
probably be more convenient.

You may ask, how would the compiler know that this "string" is meant
to be a function ?
I think it would be nice to have a similar syntax for matching strings
and for building strings. Following David's example:

q = case x of
/"^$" -> "Empty Line."
/"^(foo@\d+)" -> /"%s hello!" foo
/"confusion (foo@?) (bar@*)" -> /"foo is %s And bar is %s" foo bar
/"(a@*)" -> error (/"Sorry: I don't know what to do with %s" a)

--
"Choose Again."

Reply via email to