Skip to content

Leverage Stdlib additions in OCaml 5 - #1644

Merged
WardBrian merged 5 commits into
masterfrom
stdlib-5
Jul 13, 2026
Merged

Leverage Stdlib additions in OCaml 5#1644
WardBrian merged 5 commits into
masterfrom
stdlib-5

Conversation

@WardBrian

Copy link
Copy Markdown
Member

Follow on to #1631, #1643: The OCaml standard library now includes direct replacements for a few things we wrote ourselves or needed dependencies for:

  • Common.Let_syntax.[Result | Option]: replaced by Stdlib.[Result | Option].Syntax
  • Environment.Distance: String now has a spellcheck function
  • Out_channel and In_channel from stdio have sufficient stdlib replacements

Submission Checklist

  • Run unit tests
  • Documentation
    • If a user-facing facing change was made, the documentation PR is here:
    • OR, no user-facing changes were made

Release notes

Copyright and Licensing

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)

@WardBrian
WardBrian requested a review from nhuurre July 13, 2026 15:40
@WardBrian WardBrian changed the title Stdlib 5 Leverage Stdlib additions in OCaml 5 Jul 13, 2026
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.48%. Comparing base (9247c1d) to head (bfb077e).

Files with missing lines Patch % Lines
src/frontend/Parse.ml 75.00% 1 Missing ⚠️
src/stanc/stanc.ml 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1644      +/-   ##
==========================================
- Coverage   91.48%   91.48%   -0.01%     
==========================================
  Files          67       67              
  Lines       10009     9989      -20     
==========================================
- Hits         9157     9138      -19     
+ Misses        852      851       -1     
Files with missing lines Coverage Δ
src/core/Core.ml 100.00% <100.00%> (ø)
src/driver/Entry.ml 96.20% <100.00%> (ø)
src/frontend/Ast.ml 75.80% <100.00%> (ø)
src/frontend/Environment.ml 84.84% <100.00%> (-3.29%) ⬇️
src/frontend/Errors.ml 100.00% <ø> (ø)
src/frontend/Preprocessor.ml 98.64% <100.00%> (+0.03%) ⬆️
src/frontend/Typechecker.ml 94.87% <ø> (ø)
src/middle/Stmt.ml 78.28% <100.00%> (ø)
src/stan_math_backend/Lower_expr.ml 97.47% <100.00%> (ø)
src/stanc/CLI.ml 100.00% <100.00%> (ø)
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/frontend/Environment.ml Outdated
Comment on lines +61 to +63
let max_dist s =
let length = String.length s in
if length < 2 then 0 else if length < 10 then 2 else 4 in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct translation of the previous code but edge cases don't really make much sense. Two-character identifier shouldn't allow two edits, and the transition from 2 to 4 feels a bit sudden. Might be better to just calculate the maximum distance as length divided by two, rounded down, but no larger than 4.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the simpler criteria. I added it, with the extra caveat that I decided to base it on the length minus the length of any known suffix like _lpdf, since foo_lupdf getting 4 characters of leeway led to some weirder test results

Comment thread src/stanc/stanc.ml Outdated
@WardBrian
WardBrian requested a review from nhuurre July 13, 2026 18:36
Comment on lines 159 to +160
A returning function was expected but an undeclared identifier "if_else" was supplied.
Did you mean "inverse"?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha ha, close enough I guess.

@WardBrian
WardBrian merged commit 0b2b514 into master Jul 13, 2026
1 check passed
@WardBrian
WardBrian deleted the stdlib-5 branch July 13, 2026 18:55
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

Successfully merging this pull request may close these issues.

2 participants