Skip to content

Commit 8cad614

Browse files
committed
fix(repl): Make nx.top load nx.c and add raven.top
1 parent 8374a77 commit 8cad614

File tree

5 files changed

+40
-17
lines changed

5 files changed

+40
-17
lines changed

dune-project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@
219219
(package
220220
(name raven)
221221
(dir packages/raven)
222-
(allow_empty)
223222
(synopsis "Modern scientific computing for OCaml")
224223
(description
225224
"Raven is an ecosystem of composable libraries for numerical computing in OCaml. Tensors, automatic differentiation, neural networks, dataframes, plotting, tokenization, computer vision, reinforcement learning, and interactive notebooks.")

packages/nx/top/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
(name nx_top)
33
(public_name nx.top)
44
(modules nx_top)
5-
(libraries nx compiler-libs.toplevel)
5+
(libraries nx nx.c compiler-libs.toplevel)
66
(modes byte))

packages/quill/bin/main.ml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@
33
SPDX-License-Identifier: ISC
44
---------------------------------------------------------------------------*)
55

6-
(* Raven packages to load, in dependency order. nx.c (virtual library
7-
implementation) must come before nx so that Nx_backend is defined. *)
86
let raven_packages =
97
[
10-
"nx.c";
11-
"nx";
8+
"nx.top";
129
"nx.io";
1310
"rune";
1411
"kaun";
1512
"kaun.datasets";
1613
"hugin";
14+
"hugin.top";
1715
"sowilo";
1816
"talon";
1917
"talon.csv";
2018
"brot";
2119
"fehu";
2220
]
2321

24-
let raven_top_packages = [ "nx.top"; "hugin.top" ]
22+
let load_optional pkg =
23+
match Quill_top.load_package pkg with
24+
| () -> true
25+
| exception Fl_package_base.No_such_package _ -> false
26+
| exception exn ->
27+
Printf.eprintf "[quill] failed to load %s: %s\n%!" pkg
28+
(Printexc.to_string exn);
29+
false
2530

2631
let setup () =
2732
(* Mark packages already linked into the quill executable so that load_package
@@ -38,16 +43,10 @@ let setup () =
3843
"threads";
3944
"threads.posix";
4045
];
41-
(* Load each raven package if it is installed. *)
42-
List.iter
43-
(fun pkg ->
44-
match Quill_top.load_package pkg with
45-
| () -> ()
46-
| exception Fl_package_base.No_such_package _ -> ()
47-
| exception exn ->
48-
Printf.eprintf "[quill] failed to load %s: %s\n%!" pkg
49-
(Printexc.to_string exn))
50-
(raven_packages @ raven_top_packages)
46+
(* Prefer the umbrella top package when available; otherwise fall back to
47+
loading individual packages so partial installs still work. *)
48+
if not (load_optional "raven.top") then
49+
List.iter (fun pkg -> ignore (load_optional pkg)) raven_packages
5150

5251
let create_kernel ~on_event = Quill_top.create ~setup ~on_event ()
5352

packages/raven/top/dune

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(library
2+
(name raven_top)
3+
(public_name raven.top)
4+
(modules raven_top)
5+
(libraries
6+
nx.top
7+
nx.io
8+
rune
9+
kaun
10+
kaun.datasets
11+
hugin
12+
hugin.top
13+
sowilo
14+
talon
15+
talon.csv
16+
brot
17+
fehu)
18+
(modes byte))

packages/raven/top/raven_top.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(*---------------------------------------------------------------------------
2+
Copyright (c) 2026 The Raven authors. All rights reserved.
3+
SPDX-License-Identifier: ISC
4+
---------------------------------------------------------------------------*)
5+
6+
(* REPL convenience package for loading the Raven stack with the default Nx
7+
backend and top-level printers. *)

0 commit comments

Comments
 (0)