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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 4B0217EE51 for ; Thu, 4 Apr 2013 11:05:02 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of dhouse@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dhouse@janestreet.com"; x-sender="dhouse@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of dhouse@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dhouse@janestreet.com"; x-sender="dhouse@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@tot-dmz-mxout1.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="dhouse@janestreet.com"; x-sender="postmaster@tot-dmz-mxout1.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtoBAAlBXVEmacjlnGdsb2JhbABDgzzBBngeDgEBAQEBBg0JCRQogh8BAQVAAQE3AQ8LCw0uIQESAQUBHAYTG4dnAw8DCaIWim+EOwEFhQENiVUGjEeCHzMHg0CVDoFggR+KUYM5FimELw X-IPAS-Result: AtoBAAlBXVEmacjlnGdsb2JhbABDgzzBBngeDgEBAQEBBg0JCRQogh8BAQVAAQE3AQ8LCw0uIQESAQUBHAYTG4dnAw8DCaIWim+EOwEFhQENiVUGjEeCHzMHg0CVDoFggR+KUYM5FimELw X-IronPort-AV: E=Sophos;i="4.87,407,1363129200"; d="scan'208";a="9744625" Received: from mx5.janestreet.com (HELO tot-dmz-mxout1.janestreet.com) ([38.105.200.229]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 04 Apr 2013 11:05:01 +0200 Received: from tot-oib-smtp1.delacy.com ([172.27.22.15] helo=tot-smtp) by tot-dmz-mxout1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1UNg6M-0000IZ-Mr for caml-list@inria.fr; Thu, 04 Apr 2013 05:04:58 -0400 Received: from tot-dmz-mxgoog1.delacy.com ([172.27.224.14] helo=mxgoog2.janestreet.com) by tot-smtp with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1UNg6M-0007dp-M2 for caml-list@inria.fr; Thu, 04 Apr 2013 05:04:58 -0400 Received: from mail-ia0-f198.google.com ([209.85.210.198]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1UNg6M-00034l-Ix for caml-list@inria.fr; Thu, 04 Apr 2013 05:04:58 -0400 Received: by mail-ia0-f198.google.com with SMTP id f27so8331524iae.5 for ; Thu, 04 Apr 2013 02:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=x-received:mime-version:x-received:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=FiehjP89iPXgz5zL30zqwqeNR+RST5NgXdYzFkGs7wI=; b=wTx+a1XO5p2whfkvSTQob6l0GvaBIavjGyuqyIxUkjcE0l1fOTusvhGlpkWkJFfOKa ju9peMJwbHRusFBEqEC1sZnCbkwdEKts/hKoRbAqtgBWlrHnmfD/fbM3JwI1PJ1J4XzV iXIE14B1X6aDfWj9sDoQhKEU4KhouErq0FgqU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-received:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding:x-gm-message-state; bh=FiehjP89iPXgz5zL30zqwqeNR+RST5NgXdYzFkGs7wI=; b=pEShhXsb0Nepa472EVgeezcMnBmmDINWtauvMkrzYROiDRpv805i/yflEyd50bZEeG 27Z53Vg3VjzAZ9B0KhmA046f7XlZBKUnIH1ZwZK1/FqdYZlZPfKaLSkhrssrkTZ9nChW csgOkWsjJuQewWEAtaiTc/z4VkbJ8qgMEpjZZ6zuTFz2YlAfuUUR8ph53jkBNxT6q7fG OilvNHeqq1pVsQqJ8sWLGY2vounqRUOlFPZv9BJCVTqqInblaFfrCLyegbmIU6ve9w+/ 2NvOi8bgIRVWA6TxmYIR1EKIJDq9gQeCf4sUC2qqW2ilRjLaY7FvZduNv1Rgc4vkTz9c eEhw== X-Received: by 10.60.7.97 with SMTP id i1mr3498290oea.89.1365066298131; Thu, 04 Apr 2013 02:04:58 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.7.97 with SMTP id i1mr3498279oea.89.1365066297935; Thu, 04 Apr 2013 02:04:57 -0700 (PDT) Received: by 10.76.34.199 with HTTP; Thu, 4 Apr 2013 02:04:57 -0700 (PDT) In-Reply-To: References: Date: Thu, 4 Apr 2013 10:04:57 +0100 Message-ID: From: David House To: Anthony Tavener Cc: =?ISO-8859-1?Q?Rapha=EBl_Proust?= , "caml-list@inria.fr" Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQnl/DleBL8ujB/qOhya1YWZ61sBXQhde0pjZwL/YmNGaWU3AbwDz1zOGDC1JJRRcY3eB1xbTSpzkiSKPNoCsAXRQmuTYKiv0iCzxr0hXQuiFZCdWxLNADLUTYmHyI3NBcYCVrbPkp/NgOZ0yaKO2rSsauLtNA== Subject: Re: [Caml-list] Heterogeneous dictionary I don't quite understand the problem. Here's an example of how one might use univ_map: open Core.Std module Keys : sig val recovery : int Univ_map.Key.t val resist_pain : float Univ_map.Key.t end =3D struct let recovery =3D Univ_key.Key.create "recovery" Int.sexp_of_t let resist_pain =3D Univ_key.Key.create "resist_pain" Float.sexp_of_t end (In practice this might be two files: keys.ml with the implementation and keys.mli with the signature.) You can then add things as follows: let add map ~key ~data =3D Univ_map.add_exn map key data in let map =3D Univ_map.empty |> add ~key:Keys.recovery ~data:4 |> add ~key:Keys.resist_pain ~data:10. in ... On 4 April 2013 09:37, Anthony Tavener wrote: > Thank-you for the advice and pointers, folks... > > Well, the common problem is still the same one I've been struggling with: > "creating keys", and having to access them. > > I can't create keys "type-free" in a common module. As I figured... having > "modifier.ml" with a bunch of Key.create will have monomorphic types which > can't be resolved since with no usage in that module to make the type > concrete. I had a nagging feeling I'd need a "whole-program" compiler... > > Instead I'd have to create keys in modules where they are used... but the= n I > might have a mess of keys like Wounds.recovery, Combat.resist_pain, ... t= he > problem being that only a fraction of these keys actually make sense being > associated to a particular module, and it gets confusing to know which (of > several candidates) I decided to stash them into. This was the attraction= to > polymorphic variants (which I rarely use) -- they give a pre-ordained uni= que > ID based on a simple name... no declaration, and no module prefixing, whi= ch > seems important to me for this case. > > Note that I have a "database" of tables with different types (implemented= by > first-class modules!), and it works great for the bulk of my game-state, = but > each table is well-populated and heavily used in consistent manner. These > modifiers though... they're a bit like ad-hoc message passing, where I can > submit any message and anywhere else add a snippet of code to interpret it > (not that I have any of that going on, otherwise it might hold the > solution!). > > > > On Thu, Apr 4, 2013 at 1:38 AM, Rapha=EBl Proust wr= ote: >> >> On Thu, Apr 4, 2013 at 1:45 AM, Anthony Tavener >> wrote: >> > [=85] >> >> And yet-another-solution, Ocsigen's Polytable: >> http://ocsigen.org/ocsigenserver/api/Polytables >> >> >> Cheers, >> -- >> ______________ >> Rapha=EBl Proust > >