caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Markus Mottl" <markus.mottl@gmail.com>
To: "Jeremy Yallop" <jeremy.yallop@ed.ac.uk>
Cc: "David Teller" <David.Teller@ens-lyon.org>, OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Deriving + type-conv + OCaml-Templates + camlp4* = ?
Date: Thu, 28 Feb 2008 13:17:36 -0500	[thread overview]
Message-ID: <f8560b80802281017l3c3ccaar3b4b3fcc8c31629@mail.gmail.com> (raw)
In-Reply-To: <47C541FB.30508@ed.ac.uk>

On Wed, Feb 27, 2008 at 5:56 AM, Jeremy Yallop <jeremy.yallop@ed.ac.uk> wrote:
>  > I think that different projects have different trade-offs that are
>  > hard, if not impossible, to combine.
>
>  I fear that you may be right, although (as the author of deriving) I'd
>  be more than happy to consider collaboration, given a concrete proposal.

We'd certainly be very happy to have a general framework for deriving
code from type definitions, since we (Jane Street Capital) have been
using this idea very successfully in our projects.  Having written two
complete and fairly complex libraries of that kind, I found that the
overlap between them was so small that it almost doesn't count in
comparison to the total effort required.  Thus I'm rather skeptical
that a general purpose library for type-derived code will be possible
without giving up on performance, but I'd surely like to be
surprised....

>  This is a little more surprising, since completeness *is* a focus of
>  deriving.
>
>  If I understand you rightly, then the case you mention is actually
>  handled: are you referring to using deriving with a polymorphic variant
>  type that extends another, such as
>
>     type a = [`A]
>     type ab = [a|`B]

Right.

>  This sort of thing is certainly handled; indeed, deriving handles
>  considerably more complicated cases as well, e.g. involving various
>  sorts of recursion:

Ok, I possibly misremembered something.  Sorry about that.

Sexplib treats this issue (inherited polymorphic variant types) by
using backtracking.  This has the advantage of a clear semantics
concerning which type converter will be used if types overlap (always
the first one left-to-right).  This doesn't seem to be the case with
some Deriving generators, but this may not be a big deal there.

>  To avoid giving the impression that deriving is absolutely complete, I
>  should mention that nested (i.e. irregular) types are not handled.  This
>  is in some ways a limitation of the approach of using modules for
>  recursion.  I don't think this limitation is significant for most
>  people, but I may look into adding support at some point.

This is surely a very minor limitation.  I can't remember the last
time I encountered irregular types in real life.  Sexplib seems to
support them, though one has to pass the -rectypes flag to the
compiler, of course.

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com


  reply	other threads:[~2008-02-28 18:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-26 20:27 David Teller
2008-02-26 22:01 ` [Caml-list] " Markus Mottl
2008-02-27 10:56   ` Jeremy Yallop
2008-02-28 18:17     ` Markus Mottl [this message]
2008-02-26 22:02 ` Till Varoquaux

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=f8560b80802281017l3c3ccaar3b4b3fcc8c31629@mail.gmail.com \
    --to=markus.mottl@gmail.com \
    --cc=David.Teller@ens-lyon.org \
    --cc=caml-list@inria.fr \
    --cc=jeremy.yallop@ed.ac.uk \
    /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).