Refactor DialectFileMap to use IO.Ref for LoadedDialects#516
Merged
joehendrix merged 2 commits intomainfrom Mar 5, 2026
Merged
Refactor DialectFileMap to use IO.Ref for LoadedDialects#516joehendrix merged 2 commits intomainfrom
joehendrix merged 2 commits intomainfrom
Conversation
22b3f8c to
dfaac22
Compare
Simplify dialect-loading by replacing the pure `preloaded` field with a
mutable `IO.Ref`, eliminating the need to thread `LoadedDialects` through
return types across every call site.
- Replace `DialectFileMap.preloaded` with `DialectFileMap.loaded : IO.Ref
LoadedDialects`; add `new`, `getLoaded`, `modifyLoaded` helpers
- Remove the `LoadedDialects` element from return tuples in the mutual
block (`loadDialectFromIonFragment`, `loadDialectFromPath`,
`loadDialectRec`, `elabDialectRest`) and public wrappers (`loadDialect`,
`elabDialect`)
- Remove `DialectState.loaded` field; add `getLoadedDialects` helper in
`DialectM` that reads directly from `DialectContext.loadedRef`,
eliminating the sync pattern and stale-snapshot risk
- Simplify `LoadDialectCallback` from
`LoadedDialects → DialectName → BaseIO (LoadedDialects × Except ...)`
to `DialectName → BaseIO (Except ...)`
- Simplify `readStrataText`, `readStrataIon`, `readFile` return types in
Util/IO and SimpleAPI from `IO (LoadedDialects × ...)` to `IO ...`
- Make `loadDialectFromPath` private; add public `loadDialectFromFile`
wrapper for the `#load_dialect` call site in HashCommands
- Extract `readDialectTextfileHeader` from the mutual block for header
parsing; inline `readDialectTextfile` body into `loadDialectFromPath`
- Preload production dialects (Core, Laurel, SMT, SMTCore, SMTResponse,
smtReservedKeywordsDialect) in `buildDialectFileMap` alongside Python
and PythonSpecs
- Change `DialectFileMap.ofDirs` to accept an `init` parameter and
`addEntry` to preserve existing map fields with `{ m with ... }`
- Fix `printCommand` to use `exitFailure` instead of silent return on
internal error
- Fix line lengths and complete truncated `DialectFileMap` docstring
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
shigoel
reviewed
Mar 5, 2026
shigoel
reviewed
Mar 5, 2026
shigoel
approved these changes
Mar 5, 2026
Contributor
shigoel
left a comment
There was a problem hiding this comment.
LGTM, left a couple of questions for my own understanding.
aqjune-aws
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces the pure
DialectFileMap.preloadedfield with a mutableIO.Ref LoadedDialects, eliminating the need to threadLoadedDialectsthrough parameters and return types across every dialect-loading call
site.
The main benefit is that
strata printand other DDM CLI subcommands should be much easier to work with since they don't require dialects that are already precompiled into Strata.Details
DialectFileMap. Addedloaded : IO.Ref LoadedDialectswithnew,getLoaded,modifyLoadedhelpers.LoadedDialectsthreading. RemovedLoadedDialectsfromparameters and return tuples throughout the dialect-loading mutual
block, public API (
loadDialect,elabDialect),Util/IO, andSimpleAPI. Functions now read/write the ref directly.DialectState.loadedfield. AddedgetLoadedDialectsinDialectMthat reads from the ref, eliminating the sync pattern andstale-snapshot risk.
LoadDialectCallback. Reduced from two-argumentcallback returning a pair to a single-argument callback.
readDialectTextfileHeader; madeloadDialectFromPathprivate witha public
loadDialectFromFilewrapper.now registered in
buildDialectFileMapso strata DDM commands do not need them added as arguments.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.