Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can it run from the ocaml repl? something like #load "lymp.cmo" #18

Open
mattiasw2 opened this issue Feb 17, 2019 · 2 comments
Open

can it run from the ocaml repl? something like #load "lymp.cmo" #18

mattiasw2 opened this issue Feb 17, 2019 · 2 comments

Comments

@mattiasw2
Copy link

I use opam, and I admit there was a long time I used ocaml, more into F# the recent years. I tried this:

$ ocaml -I +threads
        OCaml version 4.05.0

# #load "unix.cma" ;;
# #load "threads.cma" ;;
# #load "/home/mattias/.opam/system/lib/lymp/lymp.cma" ;;
# open Lymp ;;
Characters 5-9:
  open Lymp ;;
       ^^^^
Error: Unbound module Lymp
# open Unix ;;
# open Mutex ;;
# 
@dbousque
Copy link
Owner

dbousque commented Feb 17, 2019

Hi @mattiasw2, I don't have much experience with the toplevel. I wasn't able to do most of what I wanted to do with it in the past, and this time once again :) I tried to use yojson in the toplevel, but got the same issue :

# #load "/Users/<user>/.opam/default/lib/easy-format/easy_format.cma" ;;
# #load "/Users/<user>/.opam/default/lib/biniou/biniou.cma" ;;
# #load "/Users/<user>/.opam/default/lib/yojson/yojson.cma" ;;
# open Yojson ;;
Error: Unbound module Yojson

Let me know if you successfully get lymp or some other package working in the toplevel.

@edwintorok
Copy link

You can use ocamlfind to load the package and its dependencies, but you have to load the thread modules first:

$ ocaml
OCaml version 4.14.1
Enter #help;; for help.

# #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 = ()
# #thread;;
/var/home/edwin/.opam/4.14.1/lib/ocaml/threads: added to search path
/var/home/edwin/.opam/4.14.1/lib/ocaml/unix.cma: loaded
/var/home/edwin/.opam/4.14.1/lib/ocaml/threads/threads.cma: loaded
# #require "lymp";;
/var/home/edwin/.opam/4.14.1/lib/lymp: added to search path
/var/home/edwin/.opam/4.14.1/lib/lymp/lymp.cma: loaded
# open Lymp;;
# 

Or you can use utop as a toplevel and then you can just require it directly:

$ utop
─( 11:56:35 )─< command 0 >───────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # #require "lymp";;
─( 11:56:35 )─< command 1 >───────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # open Lymp;;
─( 11:56:42 )─< command 2 >───────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants