caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus.mottl@gmail.com>
To: Mikhail Mandrykin <mandrykin@ispras.ru>
Cc: OCaml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Late adding of type variable constraints
Date: Wed, 9 Sep 2015 10:00:34 -0400	[thread overview]
Message-ID: <CAP_800re6cPsWFTqovANn7ShfkpCN-eMxOYtC98Us6OpNeXc0g@mail.gmail.com> (raw)
In-Reply-To: <2362538.z7Nm2DEGTb@molnar>

On Mon, Sep 7, 2015 at 2:33 PM, Mikhail Mandrykin <mandrykin@ispras.ru> wrote:
> Not sure if it's exactly what's desired, but I'd suggest Format-like
> implementation in spirit of the following:

Though it only solves part of my particular problem, this is a pretty
clever encoding to create mapping functions for structures with
arbitrary numbers of type parameters so thanks for sharing.

In my case I also need to define a type ('a t) such that I can pass it
on in a functor.  The functor body needs to know that invariants are
maintained after each mapping: the skeleton, as captured by t, and
that the same constraints hold for type parameter 'a across mappings.
Only then can the functor body easily map back and forth between
various encodings of the type parameters while maintaining the
skeleton.

Right now my solution to stay extensible is to simply syntactically
include the file containing the functors "Option", "Pair", etc., using
a macro preprocessor.  The environment into which it is included
defines the constraints on the type variables for this particular
instance.  This approach works for arbitrary constraints, which is why
I'm disappointed that this apparently cannot be done without macros.
Somehow it feels like a problem that should be easily solvable within
the core language.

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

  reply	other threads:[~2015-09-09 14:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04 20:28 Markus Mottl
2015-09-04 22:19 ` Jacques Garrigue
2015-09-04 23:58   ` Markus Mottl
2015-09-07 18:33     ` Mikhail Mandrykin
2015-09-09 14:00       ` Markus Mottl [this message]
2015-09-09 19:28         ` Mikhail Mandrykin
2015-09-11 15:56           ` Markus Mottl
2015-09-11 16:24             ` Mikhail Mandrykin

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=CAP_800re6cPsWFTqovANn7ShfkpCN-eMxOYtC98Us6OpNeXc0g@mail.gmail.com \
    --to=markus.mottl@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=mandrykin@ispras.ru \
    /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).