Browse thread
mixing infix functions and the format4 types
- Anil Madhavapeddy
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Anil Madhavapeddy <anil@r...> |
| Subject: | mixing infix functions and the format4 types |
Is there any way to mix infix operators with the Printf format6
types? I have a code printing module where this would be quite
convenient syntactically, but the obvious attempt didn't work:
$ ocaml
Objective Caml version 3.11.0
# open Printf;;
# let myfn m s = let xfn o = m ^ ": " ^ o in kprintf xfn s;;
val myfn : string -> ('a, unit, string, string) format4 -> 'a = <fun>
# myfn "foo" "bar";;
- : string = "foo: bar"
# myfn "foo" "%s %s" "bar1" "bar2";;
- : string = "foo: bar1 bar2"
# let (---) m s = myfn m s;;
val ( --- ) : string -> ('a, unit, string, string) format4 -> 'a = <fun>
# "foo" --- "bar";;;
- : string = "foo: bar"
# "foo" --- "%s %s" "bar1" "bar2";;
Error: This expression is not a function, it cannot be applied
Is there a trick to let this work, or do I need to stick to using non-
infix functions for formatting?
thanks
Anil