From: Fabrice Marchant <fabricemarchant@free.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Compose function for multiple parameters ?
Date: Sun, 1 Jun 2008 08:16:38 +0200 [thread overview]
Message-ID: <20080601081638.508b8071@free.fr> (raw)
In-Reply-To: <Pine.LNX.4.64.0805312316400.14886@martin.ec.wink.com>
On Sat, 31 May 2008 23:37:24 +0200 (CEST)
Martin Jambon <martin.jambon@ens-lyon.org> wrote:
> >>> (( <<- ) <<- ( <<- ) <<- ( <<- ))
> >>> to compose with a 3 parameters function.
> >>
> >> Personally, I call this obfuscated, not clean.
> >>
> >>
> >> Martin
> Sorry Fabrice, I'm realizing that my answer was a bit rude...
No problem.
> Stuff that is not used frequently or which is used far from its point of
> definition should receive identifiers that mean something. So what I would
> do is use no operator at all unless you use it more than 5 times in the
> same module (more or less).
I could rename ( <<-- ) to 'compose2'.
> > Defining the 2 ops :
> > let ( <<- ) f g x = f (g x)
> > let ( <<-- ) f g x y = f (g x y)
> My point is: why do you insist on having such operators? In my experience
> only the simple composition operator can be useful occasionally, locally.
I actually felt a need for them because they improve OCaml terseness.
An example where their use seems 'natural' :
module Make ( X : Set.OrderedType ) =
struct
module XSet = Set.Make( X )
module XMap = Map.Make( X )
type elt = X.t
type t = XSet.t XMap.t
...
(* degree vertice graph *)
let degree = XSet.cardinal <<-- XMap.find
(* mem_edge origin_vertice aim_vertice graph *)
let mem_edge org aim = (XSet.mem aim) <<- (XMap.find org)
Bad point : the omitted parameters compel to comment functions about their use.
> In other words, it's fun to play with such things, but in production code
> it's not useful except in some very special situations.
>
>
> Martin
I disagree because I heavily used the compose operators in several programs.
But a problem I noticed, using such kind of operators is they decrease a bit speed.
Regards,
Fabrice
prev parent reply other threads:[~2008-06-01 8:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-31 7:24 Fabrice Marchant
2008-05-31 8:10 ` [Caml-list] " Fabrice Marchant
2008-05-31 11:24 ` Martin Jambon
2008-05-31 16:05 ` Fabrice Marchant
2008-06-01 8:39 ` Florent Monnier
[not found] ` <20080531180149.04e6ac5e@free.fr>
2008-05-31 21:37 ` Martin Jambon
2008-06-01 0:04 ` Robert Fischer
2008-06-01 5:24 ` Fabrice Marchant
2008-06-01 6:16 ` Fabrice Marchant [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080601081638.508b8071@free.fr \
--to=fabricemarchant@free.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).