Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def runCompileTestsAtO1 = false
catchError {
withEnv([
'CXX=clang++-6.0',
'MACOS_SWITCH=stanc3-ocaml5.5',
'MACOS_SWITCH=stanc3-ocaml5.5-nobase',
'GIT_AUTHOR_NAME=Stan Jenkins',
'GIT_AUTHOR_EMAIL=mc.stanislaw@gmail.com',
'GIT_COMMITTER_NAME=Stan Jenkins',
Expand Down Expand Up @@ -280,7 +280,7 @@ catchError {
export PATH=/Users/jenkins/brew/bin:$PATH
eval $(opam env --switch="$MACOS_SWITCH" --set-switch)
opam update
opam install dune
opam install -y dune dune-build-info
'''
withEnv([
'SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.11.sdk',
Expand Down
19 changes: 10 additions & 9 deletions docs/core_ideas.mld
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@ This is not meant to be tutorial on the OCaml language itself, but rather on som
features and libraries of Stanc3 which may not be familiar to developers who do have
some OCaml exposure.

{1 The Jane Street standard library}
{1 Labeled standard library}

We use Jane Street's {{:https://ocaml.janestreet.com/ocaml-core/v0.14/doc/core/index.html}Core}
standard library. There are a few differences from the OCaml standard library which are instantly noticeable:
We have a module called [Std] which is used throughout the code base.
This is built on the OCaml standard library, but with a few differences:

{ul
{- Most higher-order functions such as [List.map] take a {i named} function argument.

This means a call like [List.map square [1;2;3]] will look like [List.map ~f:square [1;2;3]].}

{- Core defaults to safe operations which return {i options} rather than possibly erring.
{- A few operations are renamed.

In "normal" OCaml, [List.hd] has type ['a list -> 'a].
A call [List.hd []] will throw an exception.
By contrast, in the Jane Street libraries, the same function has type ['a list -> 'a option].
By contrast, in [Std], the same function has type ['a list -> 'a option].

Usually, a function with the suffix [_exn] recovers the original signature, e.g. [List.hd_exn : 'a list -> 'a ].}
When we have overriden the standard name, a function with the suffix [_exn] recovers the original
signature, e.g. [List.hd_exn : 'a list -> 'a ].}
}

If for some reason you {e need} functionality from the OCaml standard library that is not available in Jane Street
(be sure to triple check), you can use the module [Stdlib] to access the built-in versions.
If for some reason you {e need} functionality from the OCaml standard library that is not available from
our re-exports, you can use the module [Stdlib] to access the built-in versions.

There are a few other things we gain from these libraries. The most important idea to understand is {b deriving}.
Another difference between our code base and 'normal' OCaml is our use of {b deriving}.

{2 Deriving functions}

Expand Down
1 change: 0 additions & 1 deletion docs/dependencies.mld
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ These are automatically installed through the [scripts/install_ocaml.sh] and

- OCaml 5.5.0
- Dune 3.5+
- {{:https://ocaml.org/p/base/v0.17.3/doc/index.html}Base} v0.17.3 (a standard library replacement)
- {{:http://gallium.inria.fr/~fpottier/menhir/manual.html}Menhir} 20260209 (a parser generator and parsing library)
- {{:https://github.com/ocaml-ppx/ppx_deriving}ppx_deriving} 6.1.1 (a tool for generating boilerplate code)
- {{:https://erratique.ch/software/fmt}fmt} 0.11.0 (a library for pretty-printing of formatted text)
Expand Down
1 change: 1 addition & 0 deletions docs/index.mld
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ All contributions must follow the {{:https://github.com/stan-dev/stan/wiki/AI-Co
The major code sections of the compiler are as follows (these are links):

{!modules:
Std
Driver
Frontend
Middle
Expand Down
8 changes: 2 additions & 6 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
(depends
(ocaml
(= 5.5.0))
(base
(= v0.17.3))
(menhir
(= 20260209))
(fmt
Expand All @@ -29,10 +27,8 @@
(= 6.1.1))
ppx_compare
ppx_sexp_conv
ppx_expect
ppx_inline_test
ppx_pipebang
ppx_sexp_value
ppx_expect_nobase
(ppx_sexp_value :with-test)
(ocamlformat
(and
:with-dev-setup
Expand Down
4 changes: 2 additions & 2 deletions scripts/docker/ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ RUN mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packag
&& apt update \
&& apt install gh -y

# opam
RUN bash -c "printf '\n' | sh <(curl -fsSL https://opam.ocaml.org/install.sh)"

# opam
RUN bash -c "printf '\n' | sh <(curl -fsSL https://opam.ocaml.org/install.sh) "
Comment thread
WardBrian marked this conversation as resolved.

USER ubuntu
WORKDIR /home/ubuntu
Expand Down
7 changes: 4 additions & 3 deletions scripts/install_build_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ set -e

eval $(opam env)

opam pin -y base v0.17.3 --no-action
# until next versions of the _nobase packages are published, this avoids a heavy opam-core dependency
opam pin -y ppx_expect_nobase https://github.com/Kakadu/ppx_expect_nobase.git#3436e63f7c94887da735818933c5db138e1dac1a --no-action

opam install -y dune base.v0.17.3 menhir.20260209 ppx_deriving.6.1.1 fmt.0.11.0 yojson.3.0.0 cmdliner.2.1.1\
ppx_compare ppx_sexp_conv ppx_expect ppx_inline_test ppx_pipebang ppx_sexp_value
opam install -y dune menhir.20260209 ppx_deriving.6.1.1 fmt.0.11.0 yojson.3.0.0 cmdliner.2.1.1\
ppx_compare ppx_sexp_conv ppx_expect_nobase

eval $(opam env)
9 changes: 4 additions & 5 deletions scripts/install_build_deps_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ opam repository add windows https://github.com/ocaml-cross/opam-cross-windows.git
opam pin add -y ocaml-windows 5.5.0

# Install dependencies
opam install -y base.v0.17.3 base-windows.v0.17.3 menhir.20260209 menhir-windows.20260209 fmt.0.11.0\
fmt-windows.0.11.0 yojson.3.0.0 yojson-windows.3.0.0 cmdliner.2.1.1 cmdliner-windows.2.1.1\
ppx_deriving.6.1.1 ppx_deriving-windows.6.1.1 ppx_compare ppx_compare-windows ppx_sexp_conv\
ppx_sexp_conv-windows ppx_expect ppx_expect-windows ppx_inline_test ppx_inline_test-windows ppx_pipebang\
ppx_pipebang-windows ppx_sexp_value ppx_sexp_value-windows
opam install -y menhir.20260209 menhir-windows.20260209 fmt.0.11.0 fmt-windows.0.11.0\
yojson.3.0.0 yojson-windows.3.0.0 cmdliner.2.1.1 cmdliner-windows.2.1.1 ppx_deriving.6.1.1\
ppx_deriving-windows.6.1.1 ppx_compare ppx_compare-windows ppx_sexp_conv ppx_sexp_conv-windows\
ppx_expect_nobase ppx_expect_nobase-windows

eval $(opam env)
2 changes: 1 addition & 1 deletion scripts/install_ci_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ set -e
# ocamlformat, bisect_ppx, and odoc are needed for CI and useful for developers
opam pin -y ocamlformat 0.29.0 --no-action
opam pin -y bisect_ppx https://github.com/aantron/bisect_ppx.git#7061d643ff492b0045796357ee6917ded21fb1f0 --no-action
opam install -y ocamlformat bisect_ppx odoc sherlodoc menhirformat
opam install -y ocamlformat bisect_ppx odoc sherlodoc menhirformat ppx_sexp_value
2 changes: 1 addition & 1 deletion src/analysis_and_optimization/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
(inline_tests)
(modules_without_implementation monotone_framework_sigs)
(preprocess
(pps ppx_compare ppx_sexp_conv ppx_expect)))
(pps ppx_compare ppx_sexp_conv ppx_expect_nobase)))
98 changes: 0 additions & 98 deletions src/core/Core.ml

This file was deleted.

6 changes: 0 additions & 6 deletions src/core/dune

This file was deleted.

5 changes: 1 addition & 4 deletions src/driver/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@
stan_math_backend
analysis_and_optimization)
(instrumentation
(backend bisect_ppx))
(inline_tests)
(preprocess
(pps ppx_inline_test)))
(backend bisect_ppx)))
3 changes: 1 addition & 2 deletions src/frontend/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
(pps
ppx_compare
ppx_sexp_conv
ppx_expect
ppx_sexp_value
ppx_expect_nobase
ppx_deriving.fold
ppx_deriving.show
ppx_deriving.map)))
Expand Down
8 changes: 4 additions & 4 deletions src/middle/UnsizedType.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ let lub_ad_type xs =
let%expect_test "lub_ad_type1" =
let ads = [DataOnly; DataOnly; DataOnly; AutoDiffable] in
let lub = lub_ad_type ads in
print_s [%sexp (lub : autodifftype option)];
print_s (sexp_of_option sexp_of_autodifftype lub);
[%expect "(AutoDiffable)"]

let%expect_test "lub_ad_type2" =
let ads = [DataOnly; DataOnly; DataOnly] in
let lub = lub_ad_type ads in
print_s [%sexp (lub : autodifftype option)];
print_s (sexp_of_option sexp_of_autodifftype lub);
[%expect "(DataOnly)"]

let%expect_test "lub_ad_type3" =
let ads = [AutoDiffable; DataOnly; DataOnly; DataOnly] in
let lub = lub_ad_type ads in
print_s [%sexp (lub : autodifftype option)];
print_s (sexp_of_option sexp_of_autodifftype lub);
[%expect "(AutoDiffable)"]

(** Given two types find the minimal type both can convert to *)
Expand Down Expand Up @@ -311,6 +311,6 @@ let enumerate_tuple_names_io name (ut : t) =
let%expect_test "tuple names" =
let t = UArray (UTuple [UInt; UArray (UTuple [UReal; UComplex]); UVector]) in
let res = enumerate_tuple_names_io "foo" t in
[%sexp (res : string list)] |> print_s;
print_s (sexp_of_list sexp_of_string res);
[%expect {|
(foo.1 foo.2.1 foo.2.2 foo.3) |}]
3 changes: 1 addition & 2 deletions src/middle/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
(pps
ppx_compare
ppx_sexp_conv
ppx_expect
ppx_sexp_value
ppx_expect_nobase
ppx_deriving.map
ppx_deriving.fold
ppx_deriving.create
Expand Down
2 changes: 1 addition & 1 deletion src/stan_math_backend/Cpp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ module Tests = struct
let vector = (row_vector Double).:{Literal "3"} in
let values = [Literal "1"; Var "a"; Literal "3"] in
let e = (vector << values).@!("finished") in
print_s [%sexp (e : expr)];
print_s (sexp_of_expr e);
print_endline "";
Printing.pp_expr Fmt.stdout e;
[%expect
Expand Down
4 changes: 2 additions & 2 deletions src/stan_math_backend/Transform_Mir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ let%expect_test "Flatten slists" =
|> s ]
|> flatten_slists_list) in
let open Sexp_conv in
print_s [%sexp (stmt : (unit, unit) Stmt.t list)];
print_s (sexp_of_list (Stmt.sexp_of_t sexp_of_unit sexp_of_unit) stmt);
[%expect
{|
(((pattern
Expand Down Expand Up @@ -1005,7 +1005,7 @@ let%expect_test "collect vars expr" =
let%expect_test "insert before" =
let l = [1; 2; 3; 4; 5; 6] |> insert_before (( = ) 6) [999] in
let open Sexp_conv in
[%sexp (l : int list)] |> print_s;
print_s (sexp_of_list sexp_of_int l);
[%expect {| (1 2 3 4 5 999 6) |}]

let map_prog_stmt_lists f (p : ('a, 'b, 'c) Program.t) =
Expand Down
7 changes: 1 addition & 6 deletions src/stan_math_backend/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@
numbering)
(inline_tests)
(preprocess
(pps
ppx_sexp_conv
ppx_expect
ppx_sexp_value
ppx_deriving.make
ppx_deriving.show)))
(pps ppx_sexp_conv ppx_expect_nobase ppx_deriving.make ppx_deriving.show)))
5 changes: 1 addition & 4 deletions src/stan_math_signatures/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
(instrumentation
(backend bisect_ppx))
(modules :standard \ generate)
(private_modules generated_signatures)
(inline_tests)
(preprocess
(pps ppx_inline_test)))
(private_modules generated_signatures))

(executable
(name generate)
Expand Down
7 changes: 2 additions & 5 deletions stanc.opam
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ bug-reports: "https://github.com/stan-dev/stanc3/issues"
depends: [
"dune" {>= "3.12"}
"ocaml" {= "5.5.0"}
"base" {= "v0.17.3"}
"menhir" {= "20260209"}
"fmt" {= "0.11.0"}
"yojson" {= "3.0.0"}
"cmdliner" {= "2.1.1"}
"ppx_deriving" {= "6.1.1"}
"ppx_compare"
"ppx_sexp_conv"
"ppx_expect"
"ppx_inline_test"
"ppx_pipebang"
"ppx_sexp_value"
"ppx_expect_nobase"
"ppx_sexp_value" {with-test}
"ocamlformat" {with-dev-setup & = "0.29.0"}
"menhirformat" {with-dev-setup}
"bisect_ppx" {with-dev-setup}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(executable
(name run_bin_on_args)
(libraries core unix))
(libraries std unix))

(cram
(applies_to :whole_subtree)
Expand Down
Loading