Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Michael Alexander Hamburg <hamburg@fas.harvard.edu>
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] Re:  Correct locations for macro camlp4 extensions
Date: Tue, 24 Aug 2004 12:31:07 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0408241225050.16520@ls01.fas.harvard.edu> (raw)
In-Reply-To: <m23c2d6mt6.fsf_-_@biogw-ii-19.felk.cvut.cz>



On Tue, 24 Aug 2004, Jan Kybic wrote:

> > Which Haskell operator features does this emulate?  I know you can make an
> > operator without any camlp4 that does right-associative application, basically
>
> What I had in mind is function decomposition '.', you write
>
> ( f . g . h ) x     instead of        h ( g ( f x ) )
>
> The other operator is '$':
>
> f $ g $ h x         instead of        f ( g ( h x ) )
>
> both can save a lot of parentheses.
>

... snip ...

>    (* infix operator $, functional composition *)
>   expr: AFTER "apply"
>    [[ f = expr; "$"; g = expr -> <:expr< fun x -> $f$ ($g$ x) >> ]];
>
>

I don't think this is what you want.  The Haskell $ is a regular
right-associative operator; in particluar, it will treat

f $ g x y
as
f (g x y)
whereas this code will treat it as
f (g x) y

You can do it the Haskell way in O'Caml too, you would just have to make $
right-associative, which shoulndn't be so hard (I think the example for o
can be tweaked to do it).

Mike

-------------------
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-24 16:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-23  9:33 [Caml-list] Q: " Jan Kybic
2004-08-23 10:59 ` skaller
2004-09-03 14:37   ` Yamagata Yoriyuki
2004-09-04  2:12     ` skaller
2004-08-23 17:21 ` Michael Alexander Hamburg
2004-08-23 18:29   ` Richard Jones
2004-08-23 20:33     ` David Brown
2004-08-23 21:53       ` skaller
2004-08-23 23:16     ` Michael Alexander Hamburg
2004-08-24  7:43       ` Marcin 'Qrczak' Kowalczyk
2004-08-24  7:02   ` [Caml-list] " Jan Kybic
2004-08-24 16:31     ` Michael Alexander Hamburg [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=Pine.LNX.4.58.0408241225050.16520@ls01.fas.harvard.edu \
    --to=hamburg@fas.harvard.edu \
    --cc=caml-list@pauillac.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