Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Questions on modules
@ 2004-11-20  3:34 John F. Hughes
  0 siblings, 0 replies; only message in thread
From: John F. Hughes @ 2004-11-20  3:34 UTC (permalink / raw)
  To: caml-list


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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-20  3:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-20  3:34 Questions on modules John F. Hughes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox