How to load core in the toplevel?

Nathan Linger nlinger at janestreet.com
Thu Nov 8 17:31:06 GMT 2012


A nice way to selectively include submodules from a library packaged
up in the "Std"-style is

include struct
  open Mylib.Std
  module Foo = Foo
  module Bar = Bar
end

This is not nearly as good as if ocaml had support for syntax like
"open Mylib.Std (Foo, Bar)", but it's not so bad either.

Along with Ron, I never feel the need to do this with Core or Async.
But it is nice for other libraries that aren't so ambitious.

On Thu, Nov 8, 2012 at 11:25 AM, Yaron Minsky <yminsky at janestreet.com> wrote:
> And even if you want to pick and choose what you want to use, you
> should get things from the Std namespace.  i.e., you should grab
> things from Async.Std rather than from Async_extra.  It would be
> reasonable to do:
>
> module Core = Core.Std
> module Async = Async.Std
>
> and just qualify things by "Core" and "Async" when you wanted them.
>
> That said, I do think the Core.Std overlay is quite pleasant.
>
> y
>
> On Thu, Nov 8, 2012 at 11:06 AM, Ashish Agarwal <agarwal1975 at gmail.com> wrote:
>>> I'm very worried about the open directives
>>
>> Your concern is generally correct, but not always. If you are using Jane
>> Street Core, the implication is that you've chosen this as your standard
>> library, and doing open Core.Std is the way to use it.
>>
>>
>> On 7 Nov 2012, at 05:33, Francois Berenger <francois.ber... at gmail.com>
>> 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... at 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.
>>>>>>>>>
>>>>>>>
>>>>>
>>>>
>>



More information about the core mailing list