lymp icon indicating copy to clipboard operation
lymp copied to clipboard

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

Open mattiasw2 opened this issue 6 years ago • 2 comments

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 ;;
# 

mattiasw2 avatar Feb 17 '19 11:02 mattiasw2

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.

dbousque avatar Feb 17 '19 20:02 dbousque

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 # 

edwintorok avatar Nov 11 '23 11:11 edwintorok