From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DNS_FROM_RFC_POST,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 78FE3BBAF for ; Tue, 6 Oct 2009 05:24:44 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsIBAPRUykrRVd+smGdsb2JhbACaOT8CAQEBCAkMBxOoVY5iAQMDBYQlBIFShmU X-IronPort-AV: E=Sophos;i="4.44,510,1249250400"; d="scan'208";a="37612721" Received: from mail-iw0-f172.google.com ([209.85.223.172]) by mail1-smtp-roc.national.inria.fr with ESMTP; 06 Oct 2009 05:24:43 +0200 Received: by iwn2 with SMTP id 2so1980923iwn.1 for ; Mon, 05 Oct 2009 20:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=sPILDgKl4yVki4288wPovfRoUc+3DSYhmxWiX4vp6D0=; b=I+uzLc60/quRE7YCim6/sC5xJyQsMo8lfcOuk+VYOpM6+HW2kiPxHtF2i9LtELls+r rJtrPpHTacwS6NJEqLpHI42+g1eTZOsb9a96MO1fxHAJR8GeefMtL1F2t0JVVcn/zauZ sgsJdAaplKhBKy3pAshcY13xgxW6mT3kFThM8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=GxntcyDFAK0UOLRr6TWrq0bA3+eQc2yoIYr1OQfq713AQDczso405coKOkRBQlXy7J crYoBvtWazwkxFJuG5jqRoeHAeHDQqNpgT69g2DfEPB5JWIhStb25rd8fjcFExHvuwLN TSZygm7xfHpltm1oiZoWoxfFhrHT5nQsZ7J7Q= MIME-Version: 1.0 Sender: till.varoquaux@gmail.com Received: by 10.231.122.36 with SMTP id j36mr1637342ibr.21.1254799482970; Mon, 05 Oct 2009 20:24:42 -0700 (PDT) Date: Mon, 5 Oct 2009 23:24:42 -0400 X-Google-Sender-Auth: 9df758bf309436ad Message-ID: <9d3ec8300910052024y622eb9e1n124ffd0232a09447@mail.gmail.com> Subject: Announcing dyn.alpha01 From: Till Varoquaux To: Caml-list List Content-Type: text/plain; charset=UTF-8 X-Spam: no; 0.00; camlp:01 syntax:01 ocaml:01 ocaml:01 run-time:01 camlp:01 syntax:01 appending:01 val:01 val:01 bool:01 bool:01 recursive:01 unification:01 vals:01 I am please to announce the release of dyn (homepage https://forge.ocamlcore.org/projects/dyn/). This release is made possible by Jane Street capital who opened up the initial code. Dyn is a camlp4 syntax extension for Ocaml that: - Scaffolds injection and projection functions to an from dynamicaly typed values (`dyn`). - Reifies ocaml type representation in run-time inspectable values (`dtd`). - Provides camlp4 quotations/antiquotations to work with `dyn`s and `dtd`s. When the `pa_dyn` syntax is loaded it adds a new `type_conv` type processor that can be called by appending `with dyn` after a type definition (e.g. `type t = ... with dyn`) three values are defined: val t_of_dyn : Dyn.Data.t -> t val dyn_of_t : t -> Dyn.Data.t val dtd_of_t : Dyn.DTD.t Dynamic values (`dyn`) ---------------------- Dynamic values are represented using the ocaml type `Dyn.Data.t`: | Unit | Int of int | Float of float | Bool of bool | String of string | List of t list | Record of (string * t) list | Tuple of t list | Variant of string * t list Type representations (`dtd`) ---------------------------- The types for the `dtd`s is `Dyn.Dtd.t`. It is a straightforward mapping to `Dyn.Data.t`. Unique id and laziness are used to deal with recursive types. Quotations and antiquotations ------------------------------ The syntax extension also has experimental support for quotations and anti-quotations as syntactic sugar for values of types `Dyn.Data.t` and `Dyn.Dtd.t` both in expressions and patterns. The following is a toy function that extracts types from values using quotations and anti-quotations: let rec guess = function | <:dyn< ()>> -> <:dtd> | <:dyn< $int:_$>> -> <:dtd> | <:dyn< $float:_$>> -> <:dtd> | <:dyn< $bool:_$>> -> <:dtd> | <:dyn< $string:_$>> -> <:dtd> | <:dyn<[]>> -> <:dtd> (* Technicaly a 'a list...*) | <:dyn< $list:(h::_)$>> -> <:dtd< $guess h$ list>> (* We should do unification to get correct results. *) | <:dyn< $record:l$>> -> <:dtd< $record:(List.map (fun (name,d) -> name,guess d) l)$>> | <:dyn< $tup:t$ >> -> <:dtd< $tup:(List.map guess t)$>> | <:dyn< $variant:(n,vals)$ >> -> <:dtd< $variant:[n,List.map guess vals]$>> Contributions are more than welcome. Till