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 72F0E81792 for ; Tue, 9 Jul 2013 22:43:15 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=pra; client-ip=212.227.15.14; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=mailfrom; client-ip=212.227.15.14; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.web.de) identity=helo; client-ip=212.227.15.14; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="postmaster@mout.web.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmgBALt03FHU4w8Om2dsb2JhbABbv2uGRxYOAQEBAQEGCwsJFCiCURN7NAUoiDABFplklwIfiQmQCIJzawOXU4YRjkw X-IPAS-Result: AmgBALt03FHU4w8Om2dsb2JhbABbv2uGRxYOAQEBAQEGCwsJFCiCURN7NAUoiDABFplklwIfiQmQCIJzawOXU4YRjkw X-IronPort-AV: E=Sophos;i="4.87,1030,1363129200"; d="scan'208";a="25272850" Received: from mout.web.de ([212.227.15.14]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 Jul 2013 22:43:15 +0200 Received: from frosties.localnet ([95.208.119.3]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0LfiZ8-1UQIwK28Ve-00pK6z for ; Tue, 09 Jul 2013 22:43:14 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.80) (envelope-from ) id 1Uweki-0007sU-QL for caml-list@inria.fr; Tue, 09 Jul 2013 22:43:12 +0200 Date: Tue, 9 Jul 2013 22:43:12 +0200 From: Goswin von Brederlow To: caml-list@inria.fr Message-ID: <20130709204312.GA30194@frosties> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:dO6Xj155nD4KgjgazSvGd2DngYtwlCdV9z6qynqyKOVoD9u9JrQ wuOj5KzZ5XNiBFODygiGe4Fm7pzLRSVNWbKMrL2qmFz8L+G+AUnVNLTR9mHM85JLwu2Uft5 FmQO+dNSV9fryHbssnIUHky8g01rjeht35ZuyBQNlnn7Ux9sOuHZ8nHQ7z6jX6uxf7BHRY+ KBIV6qDdsybfzNcjM8rlQ== Subject: [Caml-list] GADTs and associative container 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 type one = ONE type two = TWO type _ g = | ONEt : one g | TWOt : two g let () = let h = H.create 0 in H.add h ONEt ONE; H.add h TWOt TWO; assert (H.find h ONEt = ONE); assert (H.find h TWOt = TWO); () 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? MfG Goswin