Browse thread
[Caml-list] operators: compose and Haskell's $ operator
-
Charles Martin
- Brian Rogoff
- Charles Martin
[
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: | Brian Rogoff <bpr@b...> |
| Subject: | Re: [Caml-list] operators: compose and Haskell's $ operator |
On Wed, 25 Apr 2001, Charles Martin wrote:
> Does someone out there have an out-of-the box solution for adding
> composition and an equivalent for Haskell's $ operator to OCaml?
>
> I've been using let (<<) f g x = f (g x) for composition, but an
You should be warned that that doesn't mix nicely with CamlP4's quotation
syntax.
>equivalent for the $ operator eludes me, as it needs to be right
>associative and of low precedence.
Maybe <->? Let's test it
# let ( <-> ) f x = f x;;
val ( <-> ) : ('a -> 'b) -> 'a -> 'b = <fun>
# (fun x -> x + 1) <-> (5 / 2) + 3;;
- : int = 6
# (fun x -> x + 1) <-> (5 / 2) * 3;;
- : int = 7
> Maybe someone with some Haskell envy has figured something out using
> camlp4?
I admit I have a little Haskell envy (type classes and the `infix` syntax :),
but I can probably live with some parentheses ...
-- Brian
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr