Loading ...
Sorry, an error occurred while loading the content.

Re: "ocaml_beginners"::[] Difficulties with example from "Objective CAML Tutorial"

Expand Messages
  • Jonathan Hayward
    Thank you; that worked nicely! ... -- Jonathan Hayward, christos.jonathan.hayward@gmail.com An Orthodox Christian author: theology, literature, et cetera. My
    Message 1 of 9 , May 1, 2009
    • 0 Attachment
      Thank you; that worked nicely!

      On Thu, Apr 30, 2009 at 4:47 PM, Jon Harrop <jon@...> wrote:

      >
      >
      > On Thursday 30 April 2009 22:17:06 Jonathan Hayward wrote:
      > > I'm trying to fiddle along as I read the Objective CAML Tutorial. At
      > > http://www.ocaml-tutorial.org/null_pointers,_asserts_and_warnings , one
      > of
      > > the examples is:
      > >
      > > open Graphics;;
      > >
      > > open_graph " 640x480";;
      > > for i = 12 downto 1 do
      > > let radius = i * 20 in
      > > prerr_endline ("radius is " ^ (string_of_int radius));
      > > set_color (if (i mod 2) = 0 then red else yellow);
      > > fill_circle 320 240 radius
      > > done;;
      > > read_line ();;
      > >
      > > When I give the first two (nonempty) lines to the interpreter, I get an
      > > error message:
      > >
      > > jhayward@jonathanscrossing ~ $ ocaml
      > > Objective Caml version 3.10.2
      > >
      > > # open Graphics;;
      > > # open_graph " 640x480";;
      > > Reference to undefined global `Graphics'
      > > #
      > >
      > > Am I trying to do something the wrong way? If I should be able to get the
      > > documented behavior by entering the script above line-by-line, then what
      > > should do differently? Or do I need to do additional setup and
      > > configuration before this will work? I'm on 64-bit Ubuntu 9.04 with (as
      > > listed above) OCaml 3.10.2.
      >
      > You need to load the graphics module. Either on the command line:
      >
      > $ ocaml graphics.cma
      > Objective Caml version 3.11.0
      >
      > #
      >
      > Or from within a top-level:
      >
      > $ ocaml
      > Objective Caml version 3.11.0
      >
      > # #load "graphics.cma";;
      > # ...
      >
      > Oooh, pretty circles. :-)
      >
      > --
      > Dr Jon Harrop, Flying Frog Consultancy Ltd.
      > http://www.ffconsultancy.com/?e
      >
      >



      --
      Jonathan Hayward, christos.jonathan.hayward@...
      An Orthodox Christian author: theology, literature, et cetera.
      My award-winning collection is available for free reading online:
      I invite you to visit my website at http://JonathansCorner.com/


      [Non-text portions of this message have been removed]
    • Jonathan Hayward
      I am trying to get a Hello, world! CGI script working using ocamlnet. On my system (Ubuntu AMD64 Jaunty), I installed the libocamlnet-ocaml,
      Message 2 of 9 , Jul 17, 2009
      • 0 Attachment
        I am trying to get a "Hello, world!" CGI script working using ocamlnet. On
        my system (Ubuntu AMD64 Jaunty), I installed the libocamlnet-ocaml,
        libocamlnet-ocaml-bin, and libocamlnet-ocaml-dev packages. However, when I
        try to '#load "ocamlnet.cma"', it bombs out saying it cannot find the file
        ocamlnet.cma.

        What can/should I be doing to load Ocamlnet2 as installed as a package?

        On Fri, May 1, 2009 at 10:23 AM, Jonathan Hayward <
        christos.jonathan.hayward@...> wrote:

        > Thank you; that worked nicely!
        >
        >
        > On Thu, Apr 30, 2009 at 4:47 PM, Jon Harrop <jon@...> wrote:
        >
        >>
        >>
        >> On Thursday 30 April 2009 22:17:06 Jonathan Hayward wrote:
        >> > I'm trying to fiddle along as I read the Objective CAML Tutorial. At
        >> > http://www.ocaml-tutorial.org/null_pointers,_asserts_and_warnings , one
        >> of
        >> > the examples is:
        >> >
        >> > open Graphics;;
        >> >
        >> > open_graph " 640x480";;
        >> > for i = 12 downto 1 do
        >> > let radius = i * 20 in
        >> > prerr_endline ("radius is " ^ (string_of_int radius));
        >> > set_color (if (i mod 2) = 0 then red else yellow);
        >> > fill_circle 320 240 radius
        >> > done;;
        >> > read_line ();;
        >> >
        >> > When I give the first two (nonempty) lines to the interpreter, I get an
        >> > error message:
        >> >
        >> > jhayward@jonathanscrossing ~ $ ocaml
        >> > Objective Caml version 3.10.2
        >> >
        >> > # open Graphics;;
        >> > # open_graph " 640x480";;
        >> > Reference to undefined global `Graphics'
        >> > #
        >> >
        >> > Am I trying to do something the wrong way? If I should be able to get
        >> the
        >> > documented behavior by entering the script above line-by-line, then what
        >> > should do differently? Or do I need to do additional setup and
        >> > configuration before this will work? I'm on 64-bit Ubuntu 9.04 with (as
        >> > listed above) OCaml 3.10.2.
        >>
        >> You need to load the graphics module. Either on the command line:
        >>
        >> $ ocaml graphics.cma
        >> Objective Caml version 3.11.0
        >>
        >> #
        >>
        >> Or from within a top-level:
        >>
        >> $ ocaml
        >> Objective Caml version 3.11.0
        >>
        >> # #load "graphics.cma";;
        >> # ...
        >>
        >> Oooh, pretty circles. :-)
        >>
        >> --
        >> Dr Jon Harrop, Flying Frog Consultancy Ltd.
        >> http://www.ffconsultancy.com/?e
        >>
        >>
        >
        >
        >
        > --
        > Jonathan Hayward, christos.jonathan.hayward@...
        > An Orthodox Christian author: theology, literature, et cetera.
        > My award-winning collection is available for free reading online:
        > I invite you to visit my website at http://JonathansCorner.com/
        >



        --
        → Jonathan Hayward, christos.jonathan.hayward@...
        → An Orthodox Christian author: theology, literature, et cetera.
        → My award-winning collection is available for free reading online:
        ☩ I invite you to visit my website at http://JonathansCorner.com/


        [Non-text portions of this message have been removed]
      • Richard Jones
        ... I think you ll also need to tell it where to find the ocamlnet.cma file, something like: #directory +ocamlnet The + sign tells it to look relative to the
        Message 3 of 9 , Jul 17, 2009
        • 0 Attachment
          On Fri, Jul 17, 2009 at 02:41:45PM -0500, Jonathan Hayward wrote:
          > I am trying to get a "Hello, world!" CGI script working using ocamlnet. On
          > my system (Ubuntu AMD64 Jaunty), I installed the libocamlnet-ocaml,
          > libocamlnet-ocaml-bin, and libocamlnet-ocaml-dev packages. However, when I
          > try to '#load "ocamlnet.cma"', it bombs out saying it cannot find the file
          > ocamlnet.cma.
          >
          > What can/should I be doing to load Ocamlnet2 as installed as a package?

          I think you'll also need to tell it where to find the ocamlnet.cma
          file, something like:

          #directory "+ocamlnet"

          The + sign tells it to look relative to the OCaml library directory
          ('ocamlc -where' will tell you that).

          Rich.

          --
          Richard Jones
          Red Hat
        • Jonathan Hayward
          Thank you for the replies. Both when I changed to #require netcgi2 ;; and added #directory +ocamlnet ;; before, I am getting a crash: I/O error: Is a
          Message 4 of 9 , Jul 20, 2009
          • 0 Attachment
            Thank you for the replies. Both when I changed to #require "netcgi2";; and
            added #directory "+ocamlnet";; before, I am getting a crash:

            I/O error: Is a directory

            The error appears to be the same if I comment out the #directory line.

            Christophe TROESTLER wrote:

            OCamlNet is a collection of modules
            http://projects.camlcity.org/projects/dl/ocamlnet-2.2.9/doc/html-main/index.html

            I recommend you use findlib to manage these, e.g. in the toplevel do

            #require "netcgi2";;

            On Fri, Jul 17, 2009 at 4:52 PM, Richard Jones <rich@...> wrote:

            >
            >
            > On Fri, Jul 17, 2009 at 02:41:45PM -0500, Jonathan Hayward wrote:
            > > I am trying to get a "Hello, world!" CGI script working using ocamlnet.
            > On
            > > my system (Ubuntu AMD64 Jaunty), I installed the libocamlnet-ocaml,
            > > libocamlnet-ocaml-bin, and libocamlnet-ocaml-dev packages. However, when
            > I
            > > try to '#load "ocamlnet.cma"', it bombs out saying it cannot find the
            > file
            > > ocamlnet.cma.
            > >
            > > What can/should I be doing to load Ocamlnet2 as installed as a package?
            >
            > I think you'll also need to tell it where to find the ocamlnet.cma
            > file, something like:
            >
            > #directory "+ocamlnet"
            >
            > The + sign tells it to look relative to the OCaml library directory
            > ('ocamlc -where' will tell you that).
            >
            > Rich.
            >
            > --
            > Richard Jones
            > Red Hat
            >
            >



            --
            → Jonathan Hayward, christos.jonathan.hayward@...
            → An Orthodox Christian author: theology, literature, et cetera.
            → My award-winning collection is available for free reading online:
            ☩ I invite you to visit my website at http://JonathansCorner.com/


            [Non-text portions of this message have been removed]
          • Richard Jones
            ... Are you using topfind? Anyway: rjones@trick:~$ rlwrap ocaml Objective Caml version 3.11.1+rc1 # #use topfind ;; - : unit = () Findlib has been
            Message 5 of 9 , Jul 23, 2009
            • 0 Attachment
              On Mon, Jul 20, 2009 at 03:03:57PM -0500, Jonathan Hayward wrote:
              > Thank you for the replies. Both when I changed to #require "netcgi2";; and
              > added #directory "+ocamlnet";; before, I am getting a crash:
              >
              > I/O error: Is a directory

              Are you using topfind?

              Anyway:

              rjones@trick:~$ rlwrap ocaml
              Objective Caml version 3.11.1+rc1

              # #use "topfind";;
              - : unit = ()
              Findlib has been successfully loaded. Additional directives:
              #require "package";; to load a package
              #list;; to list the available packages
              #camlp4o;; to load camlp4 (standard syntax)
              #camlp4r;; to load camlp4 (revised syntax)
              #predicates "p,q,...";; to set these predicates
              Topfind.reset();; to force that packages will be reloaded
              #thread;; to enable threads

              - : unit = ()
              # #require "netcgi2";;
              /usr/lib64/ocaml/unix.cma: loaded
              /usr/lib64/ocaml/pcre: added to search path
              /usr/lib64/ocaml/pcre/pcre.cma: loaded
              /usr/lib64/ocaml/netsys: added to search path
              /usr/lib64/ocaml/netsys/netsys.cma: loaded
              /usr/lib64/ocaml/netstring: added to search path
              /usr/lib64/ocaml/netstring/netstring.cma: loaded
              /usr/lib64/ocaml/netstring/netstring_top.cmo: loaded
              /usr/lib64/ocaml/netstring/netaccel.cma: loaded
              /usr/lib64/ocaml/netstring/netaccel_link.cmo: loaded
              /usr/lib64/ocaml/netcgi2: added to search path
              /usr/lib64/ocaml/netcgi2/netcgi.cma: loaded

              Rich.

              --
              Richard Jones
              Red Hat
            • Jonathan Hayward
              Thank you. When I manually gave #use topfind ;; and then #require netcgi2 ;; from the command line, it gave the same output as you give below (no apparent
              Message 6 of 9 , Jul 23, 2009
              • 0 Attachment
                Thank you.

                When I manually gave #use "topfind" ;; and then #require "netcgi2" ;; from
                the command line, it gave the same output as you give below (no apparent
                errors).

                But my script is still erroring out: I still get "I/O error: is a directory"

                #use "topfind" ;;
                #load "netcgi2" ;;
                print_string "Content-type: text/html\n" ;;
                print_string "\n" ;;
                print_string "<form action=\"ocaml\">" ;;
                (* print_string "It worked!\n";; *)
                print_string "<input type=\"text\" name=\"input\">\n" ;;
                print_string "<input type=\"submit\">" ;;
                print_string "</form>" ;;

                On Thu, Jul 23, 2009 at 7:18 AM, Richard Jones <rich@...> wrote:

                >
                >
                > On Mon, Jul 20, 2009 at 03:03:57PM -0500, Jonathan Hayward wrote:
                > > Thank you for the replies. Both when I changed to #require "netcgi2";;
                > and
                > > added #directory "+ocamlnet";; before, I am getting a crash:
                > >
                > > I/O error: Is a directory
                >
                > Are you using topfind?
                >
                > Anyway:
                >
                > rjones@trick:~$ rlwrap ocaml
                > Objective Caml version 3.11.1+rc1
                >
                > # #use "topfind";;
                > - : unit = ()
                > Findlib has been successfully loaded. Additional directives:
                > #require "package";; to load a package
                > #list;; to list the available packages
                > #camlp4o;; to load camlp4 (standard syntax)
                > #camlp4r;; to load camlp4 (revised syntax)
                > #predicates "p,q,...";; to set these predicates
                > Topfind.reset();; to force that packages will be reloaded
                > #thread;; to enable threads
                >
                > - : unit = ()
                > # #require "netcgi2";;
                > /usr/lib64/ocaml/unix.cma: loaded
                > /usr/lib64/ocaml/pcre: added to search path
                > /usr/lib64/ocaml/pcre/pcre.cma: loaded
                > /usr/lib64/ocaml/netsys: added to search path
                > /usr/lib64/ocaml/netsys/netsys.cma: loaded
                > /usr/lib64/ocaml/netstring: added to search path
                > /usr/lib64/ocaml/netstring/netstring.cma: loaded
                > /usr/lib64/ocaml/netstring/netstring_top.cmo: loaded
                > /usr/lib64/ocaml/netstring/netaccel.cma: loaded
                > /usr/lib64/ocaml/netstring/netaccel_link.cmo: loaded
                > /usr/lib64/ocaml/netcgi2: added to search path
                > /usr/lib64/ocaml/netcgi2/netcgi.cma: loaded
                >
                > Rich.
                >
                > --
                > Richard Jones
                > Red Hat
                >
                >



                --
                → Jonathan Hayward, christos.jonathan.hayward@...
                → An Orthodox Christian author: theology, literature, et cetera.
                → My award-winning collection is available for free reading online:
                ☩ I invite you to visit my website at http://JonathansCorner.com/


                [Non-text portions of this message have been removed]
              • Jonathan Hayward
                Self-correction: I think I wanted to #require instead of #load netcgi2. It s loading without error. On Thu, Jul 23, 2009 at 10:02 AM, Jonathan Hayward
                Message 7 of 9 , Jul 23, 2009
                • 0 Attachment
                  Self-correction: I think I wanted to #require instead of #load netcgi2. It's
                  loading without error.

                  On Thu, Jul 23, 2009 at 10:02 AM, Jonathan Hayward <
                  christos.jonathan.hayward@...> wrote:

                  > Thank you.
                  >
                  > When I manually gave #use "topfind" ;; and then #require "netcgi2" ;; from
                  > the command line, it gave the same output as you give below (no apparent
                  > errors).
                  >
                  > But my script is still erroring out: I still get "I/O error: is a
                  > directory"
                  >
                  > #use "topfind" ;;
                  > #load "netcgi2" ;;
                  > print_string "Content-type: text/html\n" ;;
                  > print_string "\n" ;;
                  > print_string "<form action=\"ocaml\">" ;;
                  > (* print_string "It worked!\n";; *)
                  > print_string "<input type=\"text\" name=\"input\">\n" ;;
                  > print_string "<input type=\"submit\">" ;;
                  > print_string "</form>" ;;
                  >
                  >
                  > On Thu, Jul 23, 2009 at 7:18 AM, Richard Jones <rich@...> wrote:
                  >
                  >>
                  >>
                  >> On Mon, Jul 20, 2009 at 03:03:57PM -0500, Jonathan Hayward wrote:
                  >> > Thank you for the replies. Both when I changed to #require "netcgi2";;
                  >> and
                  >> > added #directory "+ocamlnet";; before, I am getting a crash:
                  >> >
                  >> > I/O error: Is a directory
                  >>
                  >> Are you using topfind?
                  >>
                  >> Anyway:
                  >>
                  >> rjones@trick:~$ rlwrap ocaml
                  >> Objective Caml version 3.11.1+rc1
                  >>
                  >> # #use "topfind";;
                  >> - : unit = ()
                  >> Findlib has been successfully loaded. Additional directives:
                  >> #require "package";; to load a package
                  >> #list;; to list the available packages
                  >> #camlp4o;; to load camlp4 (standard syntax)
                  >> #camlp4r;; to load camlp4 (revised syntax)
                  >> #predicates "p,q,...";; to set these predicates
                  >> Topfind.reset();; to force that packages will be reloaded
                  >> #thread;; to enable threads
                  >>
                  >> - : unit = ()
                  >> # #require "netcgi2";;
                  >> /usr/lib64/ocaml/unix.cma: loaded
                  >> /usr/lib64/ocaml/pcre: added to search path
                  >> /usr/lib64/ocaml/pcre/pcre.cma: loaded
                  >> /usr/lib64/ocaml/netsys: added to search path
                  >> /usr/lib64/ocaml/netsys/netsys.cma: loaded
                  >> /usr/lib64/ocaml/netstring: added to search path
                  >> /usr/lib64/ocaml/netstring/netstring.cma: loaded
                  >> /usr/lib64/ocaml/netstring/netstring_top.cmo: loaded
                  >> /usr/lib64/ocaml/netstring/netaccel.cma: loaded
                  >> /usr/lib64/ocaml/netstring/netaccel_link.cmo: loaded
                  >> /usr/lib64/ocaml/netcgi2: added to search path
                  >> /usr/lib64/ocaml/netcgi2/netcgi.cma: loaded
                  >>
                  >> Rich.
                  >>
                  >> --
                  >> Richard Jones
                  >> Red Hat
                  >>
                  >>
                  >
                  >
                  >
                  > --
                  > → Jonathan Hayward, christos.jonathan.hayward@...
                  > → An Orthodox Christian author: theology, literature, et cetera.
                  > → My award-winning collection is available for free reading online:
                  > ☩ I invite you to visit my website at http://JonathansCorner.com/
                  >



                  --
                  → Jonathan Hayward, christos.jonathan.hayward@...
                  → An Orthodox Christian author: theology, literature, et cetera.
                  → My award-winning collection is available for free reading online:
                  ☩ I invite you to visit my website at http://JonathansCorner.com/


                  [Non-text portions of this message have been removed]
                Your message has been successfully submitted and would be delivered to recipients shortly.