caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: padiolea@irisa.fr
To: "Richard Jones" <rich@annexia.org>
Cc: "Jonathan Roewen" <jonathan.roewen@gmail.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] infix functions
Date: Fri, 27 May 2005 14:46:11 +0200 (CEST)	[thread overview]
Message-ID: <33823.131.254.50.45.1117197971.squirrel@mail.irisa.fr> (raw)
In-Reply-To: <20050527105824.GA6650@furbychan.cocan.org>

> On Fri, May 27, 2005 at 10:06:10PM +1200, Jonathan Roewen wrote:
>> Hi,
>>
>> I see some pervasive functions are infix, and I'm wondering if there's
>> any plan to support making any arbitrary infix functions?
>>
>> For instance, the Int32 (etc) modules are horrible to use cause of the
>> prefix functions. These are perfect candidates for being infix. And
>> being an OS project,

Can we access the code of this OS project ?
I know that there is another OS project with caml called funk at
  http://perso.ens-lyon.fr/samuel.mimram/docs/funk_doc/
and another one called House but with haskell
 http://www.cse.ogi.edu/~hallgren/House/
that you might be interested in.

> It's also possible to create infix functions; however you have to use
> the camlp4 preprocessor and your functions become reserved words in
> the language.  Here is an example of an infix function which should
> get you started:
>
> 	open Pcaml
>
> 	EXTEND
> 	   expr: AFTER "apply"
> 	   [ LEFTA
> 	       [ e1 = expr; "map_with"; e2 = expr ->
> 	           <:expr< List.map $e2$ $e1$ >>
> 	       ]
> 	   ];
> 	END
>
> So using that extension you could write code like:
>
> 	list map_with (fun elem -> ...)

I think it is simpler for such cases to have a generic operator such as
let (+>) o f = f o

and then just do
 [1;2;3;4] +> map (fun x -> x+1)
which is reminescent of object notation.






  reply	other threads:[~2005-05-27 12:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-27 10:06 Jonathan Roewen
2005-05-27 10:58 ` Richard Jones
2005-05-27 12:46   ` padiolea [this message]
2005-05-27 14:20     ` William D. Neumann
2005-05-27 11:12 ` Jean-Christophe Filliatre
2005-05-27 11:13 ` Vincenzo Ciancia

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=33823.131.254.50.45.1117197971.squirrel@mail.irisa.fr \
    --to=padiolea@irisa.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=jonathan.roewen@gmail.com \
    --cc=rich@annexia.org \
    /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).