From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA13614; Tue, 23 Mar 2004 21:42:32 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA13666 for ; Tue, 23 Mar 2004 21:42:31 +0100 (MET) Received: from mblmail2op.macquarie.com.au (mblmail2op.macquarie.com.au [203.202.145.21]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i2NKh3KW011961 for ; Tue, 23 Mar 2004 21:43:04 +0100 Received: from isdc1n2.macbank (isdc1n2 [10.123.0.197]) by mblmail2op.macquarie.com.au (8.12.9/8.12.9) with ESMTP id i2NKgR2P014528 for ; Wed, 24 Mar 2004 07:42:27 +1100 (EST) Received: from ntsydms03.pc.internal.macquarie.com (ntsydms03 [10.124.16.67]) by isdc1n2.macbank (8.11.7+Sun/8.11.7) with ESMTP id i2NKgQ805517 for ; Wed, 24 Mar 2004 07:42:26 +1100 (EST) Received: from nt_syd_exc02.pc.internal.macquarie.com (unverified) by ntsydms03.pc.internal.macquarie.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Wed, 24 Mar 2004 07:42:26 +1100 Received: from nt_lon_exm01.pc.internal.macquarie.com ([10.32.2.14]) by nt_syd_exc02.pc.internal.macquarie.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 24 Mar 2004 07:42:26 +1100 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C41117.57A9A748" X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 Subject: [Caml-list] Basic question about modules Date: Tue, 23 Mar 2004 20:42:22 -0000 Message-ID: <7F3CFECC66117548BE71E9D7CD2EFB504349A4@nt_lon_exm01.pc.internal.macquarie.com> Thread-Topic: Basic question about modules Thread-Index: AcQRF1eMIO1i6H//TL+Z/N+Kj9GLWQ== From: "Tim Docker" To: X-OriginalArrivalTime: 23 Mar 2004 20:42:26.0536 (UTC) FILETIME=[5A042E80:01C41117] X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; haskell:01 grips:01 ocamlc:01 unwieldy:01 mli:01 mli:01 haskell:01 grips:01 ocamlc:01 unwieldy:01 ocaml:01 ocaml:01 int:01 int:01 syntax:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 335 This is a multi-part message in MIME format. ------_=_NextPart_001_01C41117.57A9A748 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Having used haskell, I'm getting to grips with the core ocaml language, but am somewhat confused by modules. If I compile a simple file, X.ml: | module StringMap =3D Map.Make (String) |=20 | type info =3D int list StringMap.t | | type named_values =3D { | details : info | } | | ..... other stuff .... then ocamlc will automatically build a x.cmi file that exports everything. I can use this from another file Y.ml: | let x =3D X.StringMap.empty;; | | let y =3D { X.details=3DX.StringMap.add "xxx" [1;2;3] x } although the X.StringMap.fn syntax seems a bit unwieldy. If I want to restrict what gets exported, I have to write an x.mli file. Whilst I've written mli files for simple types and functions, I'm at a loss as how to write the contents of the mli file that corresponds to the one automatically generated above (specifically the StringMap bit). A pointer would be much appreciated, either how to write the .mli file, or a generally better way of doing this stuff. Thanks, Tim ------_=_NextPart_001_01C41117.57A9A748 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Basic question about modules

Having used haskell, I'm getting to grips with the = core ocaml
language, but am somewhat confused by modules.

If I compile a simple file, X.ml:

 | module StringMap =3D Map.Make (String)
 |
 | type info =3D int list StringMap.t
 |
 | type named_values =3D {
 |    details : info
 | }
 |
 | ..... other stuff ....

then ocamlc will automatically build a x.cmi file that exports
everything. I can use this from another file Y.ml:

 | let x =3D X.StringMap.empty;;
 |
 | let y =3D { X.details=3DX.StringMap.add "xxx" [1;2;3] = x }

although the X.StringMap.fn syntax seems a bit unwieldy.

If I want to restrict what gets exported, I have to
write an x.mli file. Whilst I've written mli files for simple
types and functions, I'm at a loss as how to write the contents
of the mli file that corresponds to the one automatically generated
above (specifically the StringMap bit).

A pointer would be much appreciated, either how to write the .mli
file, or a generally better way of doing this stuff.

Thanks,

Tim

------_=_NextPart_001_01C41117.57A9A748-- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners