caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Baptiste Rouquier <jrouquiethearchiveshouldhaveafewantispamtricks@ens-lyon.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Infix operators
Date: Sat, 14 Aug 2004 21:52:23 +0200 (CEST)	[thread overview]
Message-ID: <1092513143.411e6d777adcb@mouette.ens-lyon.fr> (raw)
In-Reply-To: <slrnchsodl.1sp.brown@panic.cs.bris.ac.uk>

>>I'd like to define [many] infix operators

>I came up with a totally rubbish solution to this: define an "infix-ising"
>operator like so which lets you use "long" operator names made of plain
>characters:
>
>  let (%) a b = b a
>
>  let add a b = a + b
>  let addf a b = a +. b
>
>  5 %add 6
>  10. %addf 12.


I sometimes use it as a "pipe" operator :

let (|>) x f = f x
let () = input_line stdin |> lexer |> parser' |> computation |> pretty_print

instead of

let input = input_line stdin in
let temp = lexer input in
let temp = parser' temp in
let temp = computation temp in
pretty_print temp;;

-- 
Jean-Baptiste Rouquier

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


      reply	other threads:[~2004-08-14 19:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-14 12:59 Erik de Castro Lopo
2004-08-14 13:57 ` Richard Jones
2004-08-14 17:10 ` skaller
2004-08-14 19:04 ` [Caml-list] " Julian Brown
2004-08-14 19:52   ` Jean-Baptiste Rouquier [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=1092513143.411e6d777adcb@mouette.ens-lyon.fr \
    --to=jrouquiethearchiveshouldhaveafewantispamtricks@ens-lyon.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).