caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Marie Gaillourdet <jmg@gaillourdet.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] right-associating infix application operator	camlp4 extension
Date: Wed, 10 Aug 2005 09:38:28 +0200	[thread overview]
Message-ID: <42F9AEF4.20204@gaillourdet.net> (raw)
In-Reply-To: <873bpi2tx7.wl%osiire@k8.dion.ne.jp>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

osiire@k8.dion.ne.jp schrieb:
> Maybe "@" and "^" are right-associated.
> 
> # let ( ^$ ) f x = f x;;
> val ( ^$ ) : ('a -> 'b) -> 'a -> 'b = <fun>
> # print_string ^$ List.fold_left (fun x sum -> sum ^ x) "" ^$ ["1";"2";"3"];;
> 321- : unit = ()
> 
> # let ( @$ )  f x = f x;;
> val ( @$ ) : ('a -> 'b) -> 'a -> 'b = <fun>
> #  print_string @$ List.fold_left (fun x sum -> sum ^ x) "" @$ ["1";"2";"3"];;
> 321- : unit = ()

I think this peace of code make the distinction clearer.

# let (^) a b = a,b;;
val ( ^ ) : 'a -> 'b -> 'a * 'b = <fun>
# let (-) a b = a,b;;
val ( - ) : 'a -> 'b -> 'a * 'b = <fun>

Compare the types of the following to expressions:

# 1 - 2 - 3;;
- - : (int * int) * int = ((1, 2), 3)
# 1 ^ 2 ^ 3;;
- - : int * (int * int) = (1, (2, 3))
#

Is that kind of behaviour documented? I wasn't able to find it in the
docs. Which other operator names are right associative?

Jean-Marie Gaillourdet

- --
"Make everything as simple as possible, but not simpler" (A. Einstein)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC+a70NIUNP/I5YOgRAmFyAJ46rGSHwECUaSyT1ogA5TJoS7ZAuACfQUKS
5WsMn7EBLe4cBW6WQg+I5wk=
=Yu3m
-----END PGP SIGNATURE-----


  reply	other threads:[~2005-08-10  7:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-06 23:03 Quôc Peyrot
2005-08-07  8:23 ` [Caml-list] " Christian Lindig
2005-08-10  6:21 ` osiire
2005-08-10  7:38   ` Jean-Marie Gaillourdet [this message]
2005-08-10  7:50     ` David MENTRE
2005-08-11  3:04       ` Quôc Peyrot
2005-08-11  4:50         ` Stephane Glondu
2005-08-11 10:41         ` Christian Lindig

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=42F9AEF4.20204@gaillourdet.net \
    --to=jmg@gaillourdet.net \
    --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).