caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Cannot access module members as unqualified
@ 2009-10-10  8:39 rouanvd
  2009-10-10 14:43 ` [Caml-list] " Richard Jones
  0 siblings, 1 reply; 2+ messages in thread
From: rouanvd @ 2009-10-10  8:39 UTC (permalink / raw)
  To: caml-list

Hi everyone.

I am having trouble getting my modules to work together.

I have 2 modules :

============================================
module Preprocessor =
    struct

        let run txt =
            print_endline txt;
            txt ^ txt ;;

    end;;


module Main =
    struct

        open Preprocessor;;

        let main () =
            let text = "some text" in
            run text ;;

    end;;
============================================

I want to use the 'run' function unqualified, but i get a compilation
error:

Error: Unbound value run

when I qualify the run function with 'Preprocessor.' it works fine, but I
dont want to qualify the run function.

here are the commands that I use to compile the 2 modules:

============================================

#compile the Preprocessor module & move to obj\ dir
ocamlc -c Preprocessor\Preprocessor.ml
move Preprocessor\*.c* build\obj\

#compile the Main module & move to obj\ dir
ocamlc  -I build\obj\ -c Preprocessor.cmo Main.ml
move *.c* build\obj\

#link all object files to form executable
ocamlc -o build\bin\c.exe build\obj\Preprocessor.cmo build\obj\Main.cmo

============================================

Regards
Rouan


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

* Re: [Caml-list] Cannot access module members as unqualified
  2009-10-10  8:39 Cannot access module members as unqualified rouanvd
@ 2009-10-10 14:43 ` Richard Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Jones @ 2009-10-10 14:43 UTC (permalink / raw)
  To: rouanvd; +Cc: caml-list

On Sat, Oct 10, 2009 at 10:39:46AM +0200, rouanvd@softwarerealisations.com wrote:
> ============================================
> module Preprocessor =
>     struct
> 
>         let run txt =
>             print_endline txt;
>             txt ^ txt ;;
> 
>     end;;
[...]
> ocamlc -c Preprocessor\Preprocessor.ml

The problem you have is the above code defines a module called
Preprocessor.Preprocessor.

Omit all the [module ... = struct] and [end;;] parts, and it will
work fine.

http://ocaml-tutorial.org/the_structure_of_ocaml_programs

Rich.

-- 
Richard Jones
Red Hat


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

end of thread, other threads:[~2009-10-10 14:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-10  8:39 Cannot access module members as unqualified rouanvd
2009-10-10 14:43 ` [Caml-list] " Richard Jones

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).