From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 220CFBBAF for ; Wed, 23 Dec 2009 00:38:28 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiYBALjmMEuAAtnGmWdsb2JhbACBS5l+AQEBAQEICwoHE607hTmIPoQzBA X-IronPort-AV: E=Sophos;i="4.47,439,1257116400"; d="scan'208";a="52674608" Received: from smtp03.srv.cs.cmu.edu ([128.2.217.198]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 23 Dec 2009 00:38:27 +0100 Received: from senior.home (fl-67-233-5-1.dhcp.embarqhsd.net [67.233.5.1]) (authenticated bits=0) by smtp03.srv.cs.cmu.edu (8.13.6/8.13.6) with ESMTP id nBMNcPep004609 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 22 Dec 2009 18:38:26 -0500 (EST) Received: from ecc by senior.home with local (Exim 4.69) (envelope-from ) id 1NNEJ6-0002AC-Sy for caml-list@yquem.inria.fr; Tue, 22 Dec 2009 18:38:24 -0500 Date: Tue, 22 Dec 2009 18:38:24 -0500 From: Eric Cooper To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] basic question about Functors Message-ID: <20091222233824.GA8285@localhost> Mail-Followup-To: caml-list@yquem.inria.fr References: <92e42b740912221448s54594cbbpf65076b3b2e3fa7a@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <92e42b740912221448s54594cbbpf65076b3b2e3fa7a@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: mimedefang-cmuscs on 128.2.217.198 X-Spam: no; 0.00; functors:01 functors:01 ocaml:01 mli:01 ocaml:01 val:01 restrictive:01 val:01 2009:98 wrote:01 caml-list:01 define:02 modules:02 variables:02 string:02 On Tue, Dec 22, 2009 at 05:48:57PM -0500, Keith Sheppard wrote: > I've looked through the Functors section of the ocaml tutorial > (http://www.ocaml-tutorial.org/modules) and so I see how I can declare > a StringMap like: > > > module StringMap = Map.Make(String);; > > Now I can define a function like: > > > remove_fish = StringMap.remove "fish" > > What I'm confused about is what type signature I can use in the mli > file if I want to make the remove_fish function public... The top level (or "ocaml -i") is your friend: # module StringMap = Map.Make(String);; module StringMap : ... # let remove_fish = StringMap.remove "fish";; val remove_fish : '_a StringMap.t -> '_a StringMap.t = You could use this type signature as-is, but the '_a type variables are more restrictive than necessary due to the "value restriction". To make it fully general, use "eta expansion": # let remove_fish m = StringMap.remove "fish" m;; val remove_fish : 'a StringMap.t -> 'a StringMap.t = -- Eric Cooper e c c @ c m u . e d u