From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 48B487F603 for ; Thu, 12 May 2016 09:11:02 +0200 (CEST) IronPort-PHdr: 9a23:AcLxpRbTdKiUz7Wr+xCer67/LSx+4OfEezUN459isYplN5qZpM25bnLW6fgltlLVR4KTs6sC0LqH9fmwEj1Yqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh7H0os2YMl0ArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIZoGJ/3dKUgTLFeEC9ucyVsvJWq5lH/Sl6t4X0VTmUflFJkAizC9hz8TJC55in9sONh2CCce8H3SbcuVDKw6I9kTRbpjGEMMDtvtCncg8l0yaZauw6JphplwoeSbpvGGuB5e/b0edobQyJvRMdKXCwJVoq4ZooJSeQbPP1Tr6H5qksPoxr4Dg6pUrC8ggRUj2P7iPVpm98qFhvLiUl5R4oD Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=alain.frisch@lexifi.com; spf=None smtp.mailfrom=alain.frisch@lexifi.com; spf=None smtp.helo=postmaster@mx20.yaziba.net Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=pra; client-ip=85.233.204.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=mailfrom; client-ip=85.233.204.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mx20.yaziba.net) identity=helo; client-ip=85.233.204.164; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="postmaster@mx20.yaziba.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DJAAAaLDRXkKTM6VVehA0rUrtXGoV6AoEzOxEBAQEBAQEBAREBAQEBCQsJCSEvgi2CFgEBBCMVUQsYAgImAgJXBgEMCAEBiC+qMZEBAQsefIUkgXYIgUuBA4c/glkFjV+KSIFWhCiIIII3hwiFWo8/AjaCQoFXbIgxAQEB X-IPAS-Result: A0DJAAAaLDRXkKTM6VVehA0rUrtXGoV6AoEzOxEBAQEBAQEBAREBAQEBCQsJCSEvgi2CFgEBBCMVUQsYAgImAgJXBgEMCAEBiC+qMZEBAQsefIUkgXYIgUuBA4c/glkFjV+KSIFWhCiIIII3hwiFWo8/AjaCQoFXbIgxAQEB X-IronPort-AV: E=Sophos;i="5.24,609,1454972400"; d="scan'208";a="217959230" Received: from mx20.yaziba.net ([85.233.204.164]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 12 May 2016 09:10:46 +0200 Received: from mta10.int.yaziba.net (mta10.int.yaziba.net [10.4.20.30]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx20.yaziba.net (mx10.yaziba.net) with ESMTPS id C30441A761E; Thu, 12 May 2016 09:10:45 +0200 (CEST) Received: from mta10.int.yaziba.net (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTPS id C781ECA656; Thu, 12 May 2016 09:10:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTP id B6D65CA671; Thu, 12 May 2016 09:10:45 +0200 (CEST) X-Virus-Scanned: amavisd-new at mta10.int.yaziba.net Received: from mta10.int.yaziba.net ([127.0.0.1]) by localhost (mta10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id hB-YkeiCpwe6; Thu, 12 May 2016 09:10:45 +0200 (CEST) Received: from [10.0.210.66] (unknown [185.23.92.144]) by mta10.int.yaziba.net (Postfix) with ESMTPSA id 98466CA656; Thu, 12 May 2016 09:10:45 +0200 (CEST) To: Jonathan DiLorenzo , caml-list@inria.fr References: From: Alain Frisch Message-ID: Date: Thu, 12 May 2016 09:10:45 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeekledrudekgdellecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpjgetkgfkueetnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetlhgrihhnucfhrhhishgthhcuoegrlhgrihhnrdhfrhhishgthheslhgvgihifhhirdgtohhmqeenucfkphepudekhedrvdefrdelvddrudeggeenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] PPX metaquotation question Hi Jonathan, Extension nodes (i.e. [%...] stuff) are not supported by OCaml's syntax in the context of names in type declarations, so the metaquotation in ppx_tools cannot support it. It would be possible to support something like: let name = "some_type" in let typ = [%type: string] in [%stri type [@meta.name] name = [%t typ] ] When ppx_metaquot detects a specific attribute on type declarations, it would interpret the name of the declaration as a "host" variable, not a static name. It could allow passing an expression that compute the name and then discard the concrete name: let typ = [%type: string] in [%stri type [@meta.name "some_type"] t = [%t typ] ] The same technique could be used to make other component of the type declaration "dynamic" (recursive flag, list of type parameters, type kind, etc). But I'm not convinced this a very good direction: it makes the "metaquotation" syntactic DSL more complex. It might just be better to drop the concrete syntax and use directly Ast_helper (or an extra lighter convenience layer) to build Parsetree fragments. Alain On 11/05/2016 20:30, Jonathan DiLorenzo wrote: > Hey all! > > I'm trying to construct a type declaration structure item using the > metaquotation in ppx_tools and I have two variables containing a string > with the name of the type and a Parsetree.core_type, like so: > > let name = "some_type" in > let typ = [%type: string] in > [%stri type [%??? name] = [%t typ] ] > > Is there a ??? that lets me do this? Am I going about it all wrong > somehow? Or do I need to do something like: > > open Ast_helper > > let name = "some_type" in > let typ = [%type: string] in > let type_decl = Type.mk ~manifest:typ { txt=name ; loc = !default_loc} in > Str.type_ Recursive [type_decl] > > Best, > Jonathan