[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-12-22 (23:38) |
From: | Eric Cooper <ecc@c...> |
Subject: | Re: [Caml-list] basic question about Functors |
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 = <fun> 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 = <fun> -- Eric Cooper e c c @ c m u . e d u