Re: Stream expression and compile

"Gabriel Scherer [email protected] [ocaml_beginners]" <[email protected]> Sun, 3 Jul 2016 18:09:05 -0400
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAPFanBFhxj265CZUyHrv1RcatZu89qo3gcaUohWQNB2an=Ya1Q@mail.gmail.com>
I would use either:

  ocamlfind ocamlopt -package camlp4 -syntax camlp4o walk.ml -o walk.native

or

  ocamlbuild -use-ocamlfind -package camlp4 -syntax camlp4o walk.native

ocamlfind is mentioned in
  http://ocaml.org/learn/tutorials/compiling_ocaml_projects.html
but no example with camlp4 extensions is given. On the contrary, the author
documentation's has a very clear tutorial:

http://projects.camlcity.org/projects/dl/findlib-1.6.2/doc/guide-html/quickstart.html

For ocamlbuild (which is not very useful here but easily scales to
medium-sized projects),

https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc#18-syntax-extensions

On Sun, Jul 3, 2016 at 1:42 PM, Manfred Lotz [email protected]
[ocaml_beginners] <[email protected]> wrote:

> Hi there,
> From https://ocaml.org/learn/tutorials/stream_expressions.html I
> created a file walk.ml containing the following:
>
> let rec walk dir =
>     let items =
>       try
>         Array.map
>           (fun fn ->
>              let path = Filename.concat dir fn in
>              try
>                if Sys.is_directory path then `Dir path
>                else `File path
>              with e -> `Error (path, e))
>           (Sys.readdir dir)
>       with e -> [| `Error (dir, e) |] in
>     Array.fold_right
>       (fun item rest ->
>          match item with
>          | `Dir path -> [< 'item; walk path; rest >]
>          | _ -> [< 'item; rest >])
>       items
>       [< >];;
>
>
> let () =
>     Stream.iter
>       (function
>        | `Dir path ->  Printf.printf "dir: %s%!\n" path
>        | `File path -> Printf.printf "file: %s%!\n" path
>        | `Error (path, e) ->
>            Printf.printf "error: %s (%s)%!\n" path
>              (Printexc.to_string e))
>       (walk "/tmp");;
>
>
> Running this in utop works fine when I did
> #use "topfind";;
> #camlp4o;;
>
> before.
>
>
> However, I have no idea how to create a bytecode or native executable
> from above code.
>
> If this is dead simple I would like to get a pointer to the
> documentation so that I learn what I missed to read.
>
>
> Any help appreciated.  Thanks.
>
>
> --
> Manfred
>
>
>
>
> ------------------------------------
> Posted by: Manfred Lotz <[email protected]>
> ------------------------------------
>
> Archives up to December 31, 2011 are also downloadable at
> http://www.connettivo.net/cntprojects/ocaml_beginners
> The archives of the very official ocaml list (the seniors' one) can be
> found at http://caml.inria.fr
> Attachments are banned and you're asked to be polite, avoid flames etc.
> ------------------------------------
>
> Yahoo Groups Links
>
>
>
>