How to load core in the toplevel?

Benedikt Grundmann benedikt.grundmann at gmail.com
Thu Nov 8 12:17:24 GMT 2012


I like to think about open Core.Std as the equivalent to Racket's #lang
directive.

That is open Core.Std => #lang js_ocaml

Cheers,

Bene


On 8 November 2012 11:41, Yaron Minsky <yminsky at janestreet.com> wrote:

> On Thu, Nov 8, 2012 at 3:09 AM, Francois
> <francois.berenger.fun at gmail.com> wrote:
> > What is the effect of doing an open of Core.Std (I don't need async for
> the
> > moment)?
> >
> > Does it override the standard prelude and the standard library?
>
> Yes.
>
> >
> > On Thursday, November 8, 2012 3:12:06 PM UTC+9, Malcolm wrote:
> >>
> >> Core.Std and Async.Std are designed to be opened.
> >>
> >> Francois <francois.b... at gmail.com> writes:
> >>
> >> > On Thursday, November 8, 2012 1:42:41 AM UTC+9, Anil Madhavapeddy
> wrote:
> >> >>
> >> >> You should also add "#camlp4o" so that toplevel syntax extensions
> work
> >> >> too.
> >> >>
> >> >
> >> > In the future, I think only the one from janestreet to do automatic
> >> > translations to/from s-expressions interests me.
> >> > I prefer to read standard OCaml code usually.
> >> >
> >> >
> >> >>
> >> >> I'd really recommend using 'utop' (installable via OPAM) instead of
> the
> >> >> default toplevel. It doesn't require the extra -I that the default
> >> >> toplevel
> >> >> needs, and has a really nice interactive interpreter.
> >> >>
> >> >
> >> > I have to read about it.
> >> > I'm conservative about using new things (I'm an isolated OCaml
> >> > developper,
> >> > no one nearby to help me in case
> >> > I mess with something, that's why I'm so active on mailing lists).
> >> >
> >> >
> >> >>
> >> >> My full .ocamlinit with utop is:
> >> >>
> >> >> #use "topfind"
> >> >> #camlp4o
> >> >> #thread
> >> >> #require "core.top";;
> >> >> #require "async";;
> >> >> open Core.Std
> >> >> open Async.Std
> >> >>
> >> >
> >> > Thanks for sharing this.
> >> > I'm very worried about the open directives
> >> > and try to never use them so I don't think
> >> > it would fit me for the moment.
> >> >
> >> > Best regards,
> >> > Francois.
> >> >
> >> >
> >> >
> >> >>
> >> >> -anil
> >> >>
> >> >> On 7 Nov 2012, at 05:33, Francois Berenger
> >> >> <francois.ber... at gmail.com<javascript:>>
> >> >> wrote:
> >> >>
> >> >> Thanks a lot.
> >> >>
> >> >> So, the whole recipe in my case was:
> >> >>
> >> >> ocaml -I $OCAML_TOPLEVEL_PATH
> >> >> #thread;;
> >> >> #require "core.top";;
> >> >> #require "async";;
> >> >>
> >> >> Regards,
> >> >> F.
> >> >>
> >> >> On Wednesday, November 7, 2012 12:09:15 PM UTC+9, Sebastien Mondet
> >> >> wrote:
> >> >>>
> >> >>>
> >> >>>
> >> >>> I think that one is the
> >> >>>    #thread;;
> >> >>> thing
> >> >>>
> >> >>>
> >> >>>
> >> >>>
> >> >>> On Tue, Nov 6, 2012 at 10:06 PM, Francois Berenger <
> >> >>> francois.ber... at gmail.com> wrote:
> >> >>>
> >> >>>> Thanks! That fixes the problem partially.
> >> >>>>
> >> >>>> Now, I get:
> >> >>>>
> >> >>>> # #require "core.top";;
> >> >>>> # #require "core.top";;stem/lib/core/core.cma: loaded
> >> >>>> Error: Reference to undefined global `Condition'
> >> >>>> # #require "core";;
> >> >>>> # #require "core";;m/system/lib/core/core.cma: loaded
> >> >>>> Error: Reference to undefined global `Condition'
> >> >>>> # #require "async";;
> >> >>>> # #require "async";;/system/lib/core/core.cma: loaded
> >> >>>> Error: Reference to undefined global `Condition'
> >> >>>>
> >> >>>> Any hint?
> >> >>>>
> >> >>>>
> >> >>>> On Wednesday, November 7, 2012 11:54:47 AM UTC+9, Sebastien Mondet
> >> >>>> wrote:
> >> >>>>
> >> >>>>>
> >> >>>>> I'm not sure if this is your problem, but there was something with
> >> >>>>> the
> >> >>>>> toplevel (comming with the system compiler) not knowing about opam
> >> >>>>> packages.
> >> >>>>> I have to launch:
> >> >>>>>
> >> >>>>>    ocaml -I $OCAML_TOPLEVEL_PATH
> >> >>>>>
> >> >>>>> (the variable OCAML_TOPLEVEL_PATH is set by eval `opam config
> -env`)
> >> >>>>>
> >> >>>>>
> >> >>>>> On Tue, Nov 6, 2012 at 9:37 PM, Francois Berenger
> >> >>>>> <francois.ber...@**
> >> >>>>> gmail.com> wrote:
> >> >>>>>
> >> >>>>>> Apparently, ocamlfind knows where these libraries are:
> >> >>>>>>
> >> >>>>>> $ ocamlfind -query core
> >> >>>>>> /home/berenger/.opam/system/**lib/core
> >> >>>>>> $ ocamlfind -query async
> >> >>>>>> /home/berenger/.opam/system/**lib/async
> >> >>>>>> $ ocamlfind -query async_extra
> >> >>>>>> /home/berenger/.opam/system/**lib/async_extra
> >> >>>>>>
> >> >>>>>>
> >> >>>>>> On Wednesday, November 7, 2012 11:32:43 AM UTC+9, Francois
> Berenger
> >> >>>>>> wrote:
> >> >>>>>>>
> >> >>>>>>> Hello,
> >> >>>>>>>
> >> >>>>>>> I'd like to play with core in my toplevel.
> >> >>>>>>>
> >> >>>>>>> Is there a recipe?
> >> >>>>>>>
> >> >>>>>>> I have installed everything with OPAM:
> >> >>>>>>> $ opam list | egrep "core|async"
> >> >>>>>>> async                 108.07.01  Monadic concurrency library
> >> >>>>>>> async_core            108.07.01  Monadic concurrency library
> >> >>>>>>> async_extra           108.07.01  Monadic concurrency library
> >> >>>>>>> async_unix            108.07.01  Monadic concurrency library
> >> >>>>>>> core                  108.07.01  Industrial strength alternative
> >> >>>>>>> to
> >> >>>>>>> OCaml's standard library
> >> >>>>>>> core_extended                --  Extra components that are not
> as
> >> >>>>>>> closely vetted or as stable as Core
> >> >>>>>>>
> >> >>>>>>> In my toplevel, I type
> >> >>>>>>> #use "topfind";;
> >> >>>>>>> #list;;
> >> >>>>>>>
> >> >>>>>>> Nothing about core or async shows up.
> >> >>>>>>> While parmap is there, for example.
> >> >>>>>>>
> >> >>>>>>> Is this normal?
> >> >>>>>>>
> >> >>>>>>> I guess there is some configuration file of findlib to tweak
> >> >>>>>>> somewhere.
> >> >>>>>>>
> >> >>>>>>> Regards,
> >> >>>>>>> F.
> >> >>>>>>>
> >> >>>>>>>
> >> >>>>>
> >> >>>
> >> >>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/core/attachments/20121108/da57e7ba/attachment-0001.html>


More information about the core mailing list