Version française
Home     About     Download     Resources     Contact us    
Browse thread
RE: [Caml-list] Haskell features in O'Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian.Schaller@c...
Subject: RE: [Caml-list] Haskell features in O'Caml
> The correct answer might have been a reference to the module system.
> You can specify the type of a function either in a separate *.mli-file
> or in an explicit module declaration:
> 
> # module M : sig                 
>     val mul : int -> int -> int  
>   end = struct                   
>     let mul a b = a * b          
>   end;;                          
> module M : sig val mul : int -> int -> int end
> # M.mul 2 3;;
> - : int = 6
> # module N : sig               
>     val mul : int -> int -> int
>   end = struct                 
>     let mul a b = a *. b (* Arithmetic is monomorphic - no 
> type classes *)
>   end;;                        
> Signature mismatch:
> Modules do not match:
> [...]
> 

  Unfortunately there seems to be a difference between explicit module
declaration as seen above and the separation of interface and
implementation.

  Since implementation is not automatically checked against the interface
(or did I get something wrong?), you just load you implementation (or
compile it) without using (or compiling) the appropriate interface and there
will be no complaint about mismatch in signature and structure.

  I'd prefer the compiler/desktop automatically look for interface
definition while compiling/loading.

  One more or less off-topic question about interfaces: is there a way to
see the all what's inside a module when I'm opening it using "open" (like
"module M : sig val mul : int -> int -> int end" in above example)?

  Thanks a lot!!!

bye
  Chris...
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr