preprocessing printf/regex strings (like ocaml)

Pixel pixel@mandrakesoft.com
12 May 2002 12:58:01 +0200


Jorge Adriano <jadrian@mat.uc.pt> writes:

> > > 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?

some solutions to this:

- cayenne http://www.cs.chalmers.se/~augustss/cayenne/

- ocaml's printf (special typing done by the compiler)
  http://caml.inria.fr/oreilly-book/html/book-ora076.html#toc105
- ocaml's printf could also be achieved via camlp4 (?)

- you can also give up the sugar and write it (irk!):
    format (int oo lit " is " oo str oo eol)
  instead of
    sprintf "%d is %s\n"
  see "Functional Unparsing" http://www.brics.dk/RS/98/12/
                             http://tkb.mpl.com/~tkb/software.html