Version française
Home     About     Download     Resources     Contact us    
Browse thread
Having '<<', why to use '|>' ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Eric Cooper <ecc@c...>
Subject: Re: [Caml-list] Having '<<', why to use '|>' ?
On Mon, Sep 17, 2007 at 04:36:17PM +0200, Fabrice Marchant wrote:
> let ( << ) f g x = f (g x)
> let ( |> ) x f = f x
> I usually use '<<' and wonder if we can always supersede '|>' by
> this operator ?  Does it exists a case where the use of '|>' is
> better ?

I think it's just a matter of style.  Your |> operator lets you write
"pipelines" similar to the Unix shell, in which evaluation flows
from left to right.  I've typically used this when I'm applying the
function to all its arguments.  I tend to use the traditional
composition operator (your <<), when I'm combining and passing
functional values around.

-- 
Eric Cooper             e c c @ c m u . e d u