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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 800C181799 for ; Wed, 10 Jul 2013 12:16:55 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=pra; client-ip=193.252.23.211; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain@frisch.fr) identity=mailfrom; client-ip=193.252.23.211; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="alain@frisch.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@msa.smtpout.orange.fr) identity=helo; client-ip=193.252.23.211; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain@frisch.fr"; x-sender="postmaster@msa.smtpout.orange.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqEEAIcz3VHB/BfT/2dsb2JhbABagzvBXYEndIIjAQEFJxFAARALDgoJFggHCQMCAQIBNBEGAQwBBQIBAYd5AxMIsGEiiDgEjzAzB4N1A5dXhiOLJ4MT X-IPAS-Result: AqEEAIcz3VHB/BfT/2dsb2JhbABagzvBXYEndIIjAQEFJxFAARALDgoJFggHCQMCAQIBNBEGAQwBBQIBAYd5AxMIsGEiiDgEjzAzB4N1A5dXhiOLJ4MT X-IronPort-AV: E=Sophos;i="4.87,1035,1363129200"; d="scan'208";a="25387520" Received: from msa02.smtpout.orange.fr (HELO msa.smtpout.orange.fr) ([193.252.23.211]) by mail2-smtp-roc.national.inria.fr with ESMTP; 10 Jul 2013 12:16:55 +0200 Received: from [192.168.1.111] ([92.151.124.207]) by mwinf5d59 with ME id yaGt1l00M4Uby2403aGuty; Wed, 10 Jul 2013 12:16:54 +0200 Message-ID: <51DD3496.2020304@frisch.fr> Date: Wed, 10 Jul 2013 12:16:54 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:23.0) Gecko/20100101 Thunderbird/23.0 MIME-Version: 1.0 To: Lukasz Stafiniak , Goswin von Brederlow CC: Caml References: <20130709204312.GA30194@frosties> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] GADTs and associative container Hi, This thread might of interest to you: https://sympa.inria.fr/sympa/arc/caml-list/2013-02/msg00037.html Alain On 07/09/2013 10:52 PM, Lukasz Stafiniak wrote: > On Tue, Jul 9, 2013 at 10:43 PM, Goswin von Brederlow > wrote: > > Hi, > > I'm wondering if one can have an ascociative container, like a Hashtbl.t > with dependent types (GADTs as the key, value depending on the key). > Something like this: > > module H = struct > type ('a, 'b) t = ('a, 'b) Hashtbl.t > let create : type a b . int -> (a b, a) t = > fun x -> Hashtbl.create x > let add : type a b . (a b, a) t -> a b -> a -> unit = > fun h k v -> Hashtbl.add h k v > let find : type a b . (a b, a) t -> a b -> a = > fun h k -> Hashtbl.find h k > end > > BUT: > > let create : type a b . int -> (a b, a) t = > ^^^ > Error: Unbound type constructor b > > > Is there some special syntax I'm missing or is it simply impossible to > declare such a container in the abstract? > > I think you need higher kinded types, not GADTs. Haskell has them, for > example you can write code that only depends on the type class of "b" > (which is parameterized by "a"), and "b" has signature "* -> *" or > something like that.