From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 1DA8ABC57 for ; Mon, 20 Sep 2010 16:57:28 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArcBAJITl0zRVdY2kGdsb2JhbACTcoYOAYgNCBUBAQEBCQkMBxEDH6ZdiTyCFIYmLohVAQEDBYU8BIFagyqFNA X-IronPort-AV: E=Sophos;i="4.56,394,1280700000"; d="scan'208";a="57561231" Received: from mail-bw0-f54.google.com ([209.85.214.54]) by mail3-smtp-sop.national.inria.fr with ESMTP; 20 Sep 2010 16:57:27 +0200 Received: by bwz15 with SMTP id 15so7162731bwz.27 for ; Mon, 20 Sep 2010 07:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=uw7M1hojf3GPU46+90tJZkQcu+hrmxnYddzhtkzS7Ds=; b=NxWHLS1v5Qv6XVVut0hU+pXOHgR5iWH7Snt+/Av13QOW8jIRbHBOCNDSKRinEGERIT hBns4I7epPTSsU7y8iPolLrKowNpTrCPKle5ZHA3eIp0JcFhhXF09sqwyDwnWYkuJEn8 JEfZk5Aoe3MfmsfaqpffmldLMioW9mPBv8xMw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=X8pOHq9WeL7I5lr04irPMe2gc+eJXCtvFQ/xbUDenWRA6s1UvjdMLcwc5j8Y/Smyy5 cGiOsHQ5c15w3N850451HWuhVT7Vm2OJkjtTMjJeUCxxApQ9YqB1iT+wOCOdFKJWUx3Y zoEP2qsRayu/nME0HsAtWU200HFwcsrD2i1xA= Received: by 10.204.101.133 with SMTP id c5mr6626454bko.212.1284994647159; Mon, 20 Sep 2010 07:57:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.82.166 with HTTP; Mon, 20 Sep 2010 07:57:07 -0700 (PDT) In-Reply-To: <4C97714A.6050403@inria.fr> References: <4C97714A.6050403@inria.fr> From: Ashish Agarwal Date: Mon, 20 Sep 2010 10:57:07 -0400 Message-ID: Subject: Re: [Caml-list] How can I set a type parameter of Map.Make(X) ? To: Dumitru Potop-Butucaru Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=0016e6d99b7d7b86840490b22115 X-Spam: no; 0.00; int's:01 val:01 browsed:01 beginner's:01 ocaml:01 bug:01 int's:01 val:01 browsed:01 beginner's:01 ocaml:01 bug:01 1975:98 20,:98 jacky:98 --0016e6d99b7d7b86840490b22115 Content-Type: text/plain; charset=ISO-8859-1 module M = Map.Make(String) type t = int M.t Type t is the type of maps from string's to int's. Or alternatively write a function that assumes 'a is some specific type: # let f m = M.fold (fun _ x y -> x + y) m 0;; val f : int M.t -> int = On Mon, Sep 20, 2010 at 10:35 AM, Dumitru Potop-Butucaru < dumitru.potop_butucaru@inria.fr> wrote: > > Hello, > > I'm certain most users here will consider the question trivially simple, > but I browsed the documentation without finding a solution. > > The question is quite general: Given a polymorphic definition like > Map.Make(X), where > X is some module, how can I specialize its 'a type parameter, e.g. by > setting it to Y, so that > I have maps from X to Y ? > > Yours, > Jacky Potop > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > --0016e6d99b7d7b86840490b22115 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
module M =3D Map.Make(String)

type t =3D int = M.t

Type t is the type of maps from string's t= o int's. Or alternatively write a function that assumes 'a is some = specific type:

# let f m =3D M.fold (fun _ x y -> x + y) m 0;;=
val f : int M.t -> int =3D <fun>


On Mon, Sep 20, 2010 at = 10:35 AM, Dumitru Potop-Butucaru <dumitru.potop_butucaru@inria.fr> wrote:

Hello,

I'm certain most users here will consider the question trivially simple= , but I browsed the documentation without finding a solution.

The question is quite general: Given a polymorphic definition like Map.Make= (X), where
X is some module, how can I specialize its 'a type parameter, e.g. by s= etting it to Y, so that
I have maps from X to Y ?

Yours,
Jacky Potop

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.in= ria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


--0016e6d99b7d7b86840490b22115--