From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 01D987F1AB for ; Wed, 9 Sep 2015 16:00:41 +0200 (CEST) IronPort-PHdr: 9a23:XtmxKRz5iQZ+JALXCy+O+j09IxM/srCxBDY+r6Qd0eIUIJqq85mqBkHD//Il1AaPBtWHrasYwLWO+4nbGkU+or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkItf6KuStKU1pj8iLj60qaQSjsLrQL1Wal1IhSyoFeZnegtqqwmFJwMzADUqGBDYeVcyDAgD1uSmxHh+pX4p8Y7oGx48sgs/M9YUKj8Y79wDfkBVGxnYCgJ45jOtBrDRAqLrl4VVGkMgxlJBUCR6Rj8Uo3gsSr8nutmwDOTJovsUOZndy6l6vJOQQXrlTxPEjkl7GWf3sl5lqFGu1SkoABjx6bbZYiUMLx1eaaLLoBSfnZIQssED38JOYi7dYZaSrNZZes= Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=markus.mottl@gmail.com; spf=Pass smtp.mailfrom=markus.mottl@gmail.com; spf=None smtp.helo=postmaster@mail-ig0-f171.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of markus.mottl@gmail.com) identity=pra; client-ip=209.85.213.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="markus.mottl@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of markus.mottl@gmail.com designates 209.85.213.171 as permitted sender) identity=mailfrom; client-ip=209.85.213.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="markus.mottl@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ig0-f171.google.com) identity=helo; client-ip=209.85.213.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="markus.mottl@gmail.com"; x-sender="postmaster@mail-ig0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AOBQACO/BVnKvVVdFdg0I1aQaDHroCAYF2hgECgS8HPQ8BAQEBAQEBARABAQEBAQYNCQkhLoIdggcBAQQSER0BFAcdAQMMBgULDQICJgICIQEBEQEFARwGExsHh3YBAxKoDIEvPjGLQIFsgnmKDQoZJw1WhBoBAQEBAQUBAQEBARcBBQ6BFIVRhHuCT4I9B4JpgUMFlVaLDYFtkzyFcBIjgReCKYIZIjOISQEBAQ X-IPAS-Result: A0AOBQACO/BVnKvVVdFdg0I1aQaDHroCAYF2hgECgS8HPQ8BAQEBAQEBARABAQEBAQYNCQkhLoIdggcBAQQSER0BFAcdAQMMBgULDQICJgICIQEBEQEFARwGExsHh3YBAxKoDIEvPjGLQIFsgnmKDQoZJw1WhBoBAQEBAQUBAQEBARcBBQ6BFIVRhHuCT4I9B4JpgUMFlVaLDYFtkzyFcBIjgReCKYIZIjOISQEBAQ X-IronPort-AV: E=Sophos;i="5.17,496,1437429600"; d="scan'208";a="145247286" Received: from mail-ig0-f171.google.com ([209.85.213.171]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 09 Sep 2015 16:00:37 +0200 Received: by igbkq10 with SMTP id kq10so100120241igb.0 for ; Wed, 09 Sep 2015 07:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=HvnoaWgTPwY7FPnbsbSn43Y3sObsyd8ccxW293xMgTE=; b=Gp5XoQkkpMNV2T2zLjRKwMgNUCfJxXmJr8UaLptTQVPUbxjN7o4M3ctTR8n0F/XVED mIcZcJHWFqm1RO3I9SXAljSHSSN1e6wbixLJMhGEMgVFVtftAmrokVcPvOMixbXigKIl narhVtXmVCe5iuCVcIQUy9j+iHcaJzfSwtj++/vht2/+55j7TfpCJj+I75E8OztDFwnU AteI+J+LOH9Bj68+/ykZ3Ks6d8+z5vgWt5yGU8iIjNGxt4nVf7bdYtUSwfY2Ffig5zOD T/1yGZnYTkqsEpiUehtBqUskXVnWzJY1GV2S3aXDBjjHjLjrhSZTUFfoJmubUyF67wbo DZXA== MIME-Version: 1.0 X-Received: by 10.50.79.129 with SMTP id j1mr49591277igx.7.1441807234628; Wed, 09 Sep 2015 07:00:34 -0700 (PDT) Received: by 10.79.65.144 with HTTP; Wed, 9 Sep 2015 07:00:34 -0700 (PDT) In-Reply-To: <2362538.z7Nm2DEGTb@molnar> References: <2362538.z7Nm2DEGTb@molnar> Date: Wed, 9 Sep 2015 10:00:34 -0400 Message-ID: From: Markus Mottl To: Mikhail Mandrykin Cc: OCaml List Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] Late adding of type variable constraints On Mon, Sep 7, 2015 at 2:33 PM, Mikhail Mandrykin 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