caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* compilation with modules
@ 2006-11-17 18:02 Francois Colonna
  2006-11-17 18:30 ` [Caml-list] " Luc Maranget
  0 siblings, 1 reply; 2+ messages in thread
From: Francois Colonna @ 2006-11-17 18:02 UTC (permalink / raw)
  To: caml-list

Hello

Could somebody tell me how to compile a piece of code ( "my_code.ml")  using
a module ("my_tools.ml")

Here are the files :
___ my_tools.ml ____

module My_tools =
struct
let print_a_string a_string  =
    print_string (a_string)
;;
end

and
 ___ my_code.ml ____

open My_tools
let a_string = "a string" ;;
print_a_string a_string ;;


Thanks
François Colonna


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] compilation with modules
  2006-11-17 18:02 compilation with modules Francois Colonna
@ 2006-11-17 18:30 ` Luc Maranget
  0 siblings, 0 replies; 2+ messages in thread
From: Luc Maranget @ 2006-11-17 18:30 UTC (permalink / raw)
  To: Francois Colonna; +Cc: caml-list

> Hello
> 
> Could somebody tell me how to compile a piece of code ( "my_code.ml")  using
> a module ("my_tools.ml")
> 
> Here are the files :
> ___ my_tools.ml ____
> 
> module My_tools =
> struct
> let print_a_string a_string  =
>    print_string (a_string)
> ;;
> end
> 
> and
> ___ my_code.ml ____
> 
> open My_tools
> let a_string = "a string" ;;
> print_a_string a_string ;;
> 
> 
> Thanks
> François Colonna
> 

Just change my_code.ml
--- my_code.ml ---

open My_tools.My_tools
let a_string = "a string" ;;
print_a_string a_string ;;
---------------------

compile as follows

ocamlc my_tools.ml my_code.ml

Basically the file a.ml is interpreted by the compiler
as

module A = struct
  contents of a.ml
end

There is a more complete description in the manual
<http://caml.inria.fr/pub/docs/manual-ocaml/manual004.html>
(At the end)

Hope it helps,


-- 
Luc Maranget


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-11-17 18:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-17 18:02 compilation with modules Francois Colonna
2006-11-17 18:30 ` [Caml-list] " Luc Maranget

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).