caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Dawid Toton <d0@wp.pl>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Re: function that works on different record types, assuming they have a given field
Date: Wed, 30 Mar 2011 16:15:05 +0200	[thread overview]
Message-ID: <AANLkTimvCbVG8YFzwVHvw2pPvzZQV2LOxd-yv_Ssk+-_@mail.gmail.com> (raw)
In-Reply-To: <4D932456.4000803@wp.pl>

[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]

Why not pass the value of the "x" field directly to the function, instead of
trying to receive a would-be { x : 'a; .... } parameter ?
If you would have liked the field to be mutable, make it a reference.

On Wed, Mar 30, 2011 at 2:38 PM, Dawid Toton <d0@wp.pl> wrote:

> On 03/28/2011 08:35 PM, Joel Reymont wrote:
> > On Mar 28, 2011, at 7:34 PM, David Rajchenbach-Teller wrote:
> >
> >> you can obtain the same behavior by using objects instead of records:
> > Yes, that used to work very well... until I was forced to switch to
> records :-).
> >
> When I had this problem I used one common record type:
>
> type ('foo, 'bar') common =
>  {foo : 'foo
>  ;bar : 'bar
>  ;x : int
>  }
>
> type with_bar = (unit, string) common
> type with_foo = (double, unit) common
>
> However, I can see that with more different independent types this is
> going to be quite ugly.
>
> Dawid
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

[-- Attachment #2: Type: text/html, Size: 1795 bytes --]

      reply	other threads:[~2011-03-30 14:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-28 18:16 [Caml-list] " Joel Reymont
2011-03-28 18:34 ` David Rajchenbach-Teller
2011-03-28 18:35   ` Joel Reymont
2011-03-30 12:38     ` [Caml-list] " Dawid Toton
2011-03-30 14:15       ` Gabriel Scherer [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=AANLkTimvCbVG8YFzwVHvw2pPvzZQV2LOxd-yv_Ssk+-_@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=d0@wp.pl \
    /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).