Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 
reasonable: 

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

let x = 5;;

and

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

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

2. types and signatures are less strongly analogous, because "having a
certain
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;;

and

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

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
end;;

----
Can someone give me a reason for this design decision? 

I appreciate your help...

--John Hughes