English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Questions on modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-11-20 (03:34)
From: John F. Hughes <jfh@c...>
Subject: Questions on modules

I'm trying to make sense of the module language; I find that there
are useful analogies with the "value language" (where there are 
variables, functions, etc.) It appears that the following are 

1. "module" has a meaning corresponding to "let"; I see

let x = 5;;


module T = struct
  type t = int
  let c = 1

as analogous -- both establish bindings for names, more or less. 

2. types and signatures are less strongly analogous, because "having a
type" is more restrictive than "matching a signature", but still,
"module type" 
seems to be analogous to "type". 

let x:int = 5;;

module type FOO = sig type t end;;


module T:FOO = struct
  type t = int
  let c = 1

seem analogous as well. 

But I'm allowed to write

let (x:int) = 5

and *not* allowed to write 

module (T:FOO) = struct
  type t = int
  let c = 1

Can someone give me a reason for this design decision? 

I appreciate your help...

--John Hughes