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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 316627ED1A for ; Thu, 17 May 2012 18:23:39 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtACAKoktU/RVdi2imdsb2JhbABEszUIIgEBAQoJDQcSBiOCFgEBBBICExkBOAEDDAEFBQs7IhIBBQEcBhMIGodeAwudLwkDjxWFKCcNiU0BBQyQXgOVeo5gPYFYgjY X-IronPort-AV: E=Sophos;i="4.75,610,1330902000"; d="scan'208";a="158809004" Received: from mail-qc0-f182.google.com ([209.85.216.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 17 May 2012 18:23:38 +0200 Received: by qcsg15 with SMTP id g15so2116038qcs.27 for ; Thu, 17 May 2012 09:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=l+BjwpMTuXn8OyZG7wEXQZcgjtwNloL0E+QwEcmapMo=; b=IobpTu9qgnO3yL8WJL8ACdHI9XUOe506WSSBt7fVVOHjcmXCr6MY/pavAejpJByOxg ANaC4Oax+cg98yJPiSvCnPdNlhKpB9rBlqchcRdny7VaejzZ+IkUIYUNc19/ByPvVOqL ftTuHJyFQV74kiMSO1yNk0CNCfUl2ym09i09zhBhmtD6Hm98tnNcrxu68RiFaS1gpEy3 diR1jufBuG7H9bA1ZRBR1C6dDrB5UQFPeSa4jG/URPeQlBBIVOMuuiw647W94gty+Nez 9+zqVP5WFo3tk7+e3dZU25TJmZq1E028xOhHiW5W6a3ibqjm83FpHxtrJG93dMJd70Dw OcHA== MIME-Version: 1.0 Received: by 10.224.117.16 with SMTP id o16mr17492425qaq.8.1337271817509; Thu, 17 May 2012 09:23:37 -0700 (PDT) Sender: nicolas.braudsantoni@gmail.com Received: by 10.224.174.10 with HTTP; Thu, 17 May 2012 09:23:37 -0700 (PDT) In-Reply-To: References: Date: Thu, 17 May 2012 18:23:37 +0200 X-Google-Sender-Auth: CHR7_l1y7LQUPclfeWNy1nIYpz8 Message-ID: From: Nicolas Braud-Santoni To: Arnaud Spiwack Cc: OCaML Mailing List Content-Type: text/plain; charset=ISO-8859-1 X-Validation-by: nicolas@braud-santoni.eu Subject: Re: [Caml-list] One-value functors Hi, If I'm not mistaken, you want something like Haskell's typeclasses. I agree that it's a feature I often find myself wanting in OCaml, and -as you point out- is trivial to encode with module and functors, so it shouldn't be highly problematic. Is there some syntax extension providing such a feature ? If not, are there plans to have syntax for typeclass-like functor operations ? Regard, Nicolas 2012/5/11 Arnaud Spiwack : > Dear all, > > With the advent of first-class modules, I find myself more and more wanting > to write functors with only one (value) component, just to benefit from type > dependencies. >[...] > > We could have the type >> (X:A) => t > > stand for (something like) >> module F = functor (X:A) -> sig val x : t end >> (module F) > > and the definition >> let f {{X:A}} = e > > stand for >> let f = let module F (X:A) -> struct let x = e end > > and finally we'd need an application >> e {{M}} > > would stand for (something like) >> let module F = (val e) in let module F' = F(M) in F'.x > > Clearly the application needs something like OCaml 4.0 and the type > definition some kind of cleverness (I don't know, by the way, why the syntax > for F cannot be inlined in the type). > [...]