optics-dev/Monocle
50.8
Adequate · 14 November 2026
7.8k
lines of production code
Scala
primary language
7
measurements over time
What this system is
Features
Add Monocle integration for eu.timepit.refined types
This change introduces a new \refined\ module that provides Monocle optics (Prisms and At instances) for types validated by the \eu.timepit.refined\ library. Users can now use \lowerCase\ and \upperCase\ Prisms for character refinement, \startsWith\ and \endsWith\ Prisms for string refinement, and \At\ instances to access individual bits in Byte, Char, Int, and Long values constrained by bit-width intervals. The module includes internal support for bitwise operations and comprehensive property-based tests for these new capabilities.
refined · high confidence
Add Scala 3 implementation for the 'as' focus keyword
The library now supports the 'as' keyword within the Focus DSL for Scala 3 users. This change introduces the parser and code generator for the 'as' feature, allowing users to explicitly cast or view a focus target as a subtype (e.g., \focus(x).as\[SubType\]\). The implementation validates that the target type is a subtype of the source type at compile time, providing a clear error if an invalid downcast is attempted.
core/shared/src/main/scala-3/monocle/internal/focus/features/as · high confidence
Added JVM-specific string-to-URL prism
A new platform-specific optic for the JVM target allows converting a String to a java.net.URL using a Prism. This addition provides a safe, optional conversion mechanism for URL parsing within the core library's standard optics on JVM platforms.
core/jvm · high confidence
Added Scala 3 macro implementations for focus keywords
The library now includes Scala 3-specific macro generators and parsers for the \at\, \each\, \index\, \some\, and \withDefault\ focus keywords. This enables users to utilize these specific navigation and transformation operations within the focus DSL when compiling with Scala 3.
(repo-wide) · high confidence
Added platform-specific string optics for Scala Native
A new \PlatformSpecificStringOptics\ trait has been introduced in the \core/js-native\ module to provide string-related optics tailored for the Scala Native platform, supporting cross-build compatibility.
core/js-native · high confidence
Internal support for bounded type casting and option monoids
The library now includes internal utilities to safely cast values based on type bounds and to combine optional values using first/last semantics. A new \Bounded\ trait and its instances for primitive types (Boolean, Byte, Char, Int) enable safe casting via \orderingBoundedSafeCast\, which validates that a source value falls within the target type's min/max range before casting. Additionally, \Monoids\ provides \firstOption\ and \lastOption\ monoids for \Option\[A\]\, allowing users to combine optional values by preserving either the first or last non-empty value, along with \any\ and \all\ monoids for Boolean conjunction/disjunction.
core/shared/src/main/scala/monocle/internal · high confidence
Introduce Scala 3 Focus macro for ergonomic optics
Adds a new \Focus\ macro API for Scala 3, enabling users to create lenses, prisms, and other optics using simple lambda syntax (e.g., \Focus\Address\\) and compose them with \.andThen\ or the new \.refocus\ extension. This change introduces the \Focus\ object, associated syntax traits (\AppliedFocusSyntax\, \ComposedFocusSyntax\), and the underlying macro implementation (\FocusImpl\) which parses lambda structures to generate type-safe optic code, along with improved error messages for macro failures.
core/shared/src/main/scala-3 · high confidence
Scala 2 macro implementation for lenses, isos, and prisms
This change introduces the Scala 2-specific macro implementations for monocle's core optics. It adds \GenLens\ for generating lenses from case class fields, \GenIso\ for creating isomorphisms between case classes and their fields (or \Unit\), and \GenPrism\ for subtyping checks. It also includes the \@Lenses\ and \@PLenses\ macro annotations that automatically generate lens definitions for case classes, along with the necessary syntax traits (\AppliedFocusSyntax\, \MacroSyntax\) to enable fluent API usage like \focus\ and \refocus\ on the Scala 2 platform.
macro/src/main/scala-2 · high confidence
Support for selecting fields in case classes, single-field case classes, and named tuples
The Focus macro now supports selecting individual fields from case classes, single-field case classes, and Scala 3 named tuples. For standard case classes, it generates a Lens to get and set the field. For single-field case classes, it generates an Iso, allowing the value to be treated as the case class itself. For named tuples, it generates a Lens for multi-element tuples and an Iso for single-element tuples, enabling direct access to fields by name.
core/shared/src/main/scala-3/monocle/internal/focus/features/selectfield · high confidence
Behavioural changes
51 commits (2 fixes) modifying core/shared/src/main/scala/monocle
A change to existing behaviour in core/shared/src/main/scala/monocle — 51 commits (2 fixs), 3 files: “Update scalafmt (\#843)”; “cats 1.0.0-RC1 (\#539)”; “fix \#901 add some to all optics (\#902)”; and 47 more (refs \#843, \#539, \#901, \#902, \#1115, …).
core/shared/src/main/scala/monocle · medium confidence · unverified
Deprecated Scala 2 generic optics for HLists, products, and coproducts
The \monocle.generic\ module for Scala 2 now exposes deprecated (since 3.0.0-M1) utilities for working with generic representations, including HList operations (such as \hListAt\, \toHList\, \fromHList\, and field accessors), product and tuple transformations (like \productToTuple\ and \tupleReverse\), and coproduct isomorphisms (such as \coProductPrism\ and conversions to \Either\). These changes, implemented in \All.scala\, \CoProduct.scala\, \Generic.scala\, \HList.scala\, \Product.scala\, and \TupleN.scala\, are accompanied by comprehensive property-based tests in \CoproductSpec\, \HListSpec\, and \ProductSpec\ to verify the correctness of these generic optics.
generic · high confidence
Deprecated unsafe Map and select operations
The unsafe module now includes deprecated MapTraversal and UnsafeSelect utilities. MapTraversal provides an Iso and Traversal for Map key-value pairs, along with a FilterIndex instance, while UnsafeSelect offers a Prism for filtering. Both are marked for removal in favor of the safer optic.filter(predicate) API.
unsafe · high confidence
Deprecation of legacy collection lens laws
The law discipline tests for the legacy collection functions Cons, Cons1, Empty, Possible, Reverse, and Snoc are now marked as deprecated (since 3.0.0-M1) with no replacement, signaling that these specific lens implementations are being phased out. The test suites for At, Each, FilterIndex, and Index remain active and unchanged, ensuring that current, supported collection traversal and access laws continue to be validated.
law/src/main/scala/monocle/law/discipline/function · high confidence
Deprecation of legacy typeclasses and consolidation into All
The \monocle.function\ package has been reorganized to prepare for version 3.0.0. Several legacy typeclasses—\Cons\, \Cons1\, \Curry\, \Empty\, \Possible\, \Reverse\, and \Snoc\—are now deprecated with no direct replacement, while \Field1\ through \Field6\ are deprecated in favor of using \Focus\ with tuple selectors. To simplify imports and usage, a new \All\ object has been introduced that aggregates all function optics (including \At\, \Each\, \Index\, \FilterIndex\, \Plated\, and the remaining non-deprecated fields) into a single mixin, allowing users to import all available functions via \import monocle.function.All.\_\.
core/shared/src/main/scala/monocle/function · high confidence
Optic hierarchy refactoring and Scala 3 Focus macro foundation
The optic traits (Fold, Getter, Lens, Optional, Prism, Iso) have been restructured to establish a clear inheritance hierarchy where all optics extend Fold, and composition is standardized via the \andThen\ method, deprecating older symbolic operators. This change also introduces the internal Scala 3 \FocusBase\ macro infrastructure, providing the parser and keyword handling logic required for the new \Focus\ DSL, while adding benchmark models to support performance testing of these core structures. Also in this area: Deprecation of legacy typeclasses and consolidation into All.
core/shared/src/main/scala/monocle/syntax, repository · high confidence
Project branding, documentation site, and contributor guidelines updated
The project has rebranded from 'Lens' to 'Monocle', updating the README to display the new logo and direct users to the official documentation website at optics.dev. A Code of Conduct and a contributor Process document have been added to establish community standards and release procedures. Additionally, the build environment is now configured with a Scala Steward configuration for automated dependency updates, a .scalafmt.conf file enforcing specific code formatting rules (including Scala 2.13 dialect support), and a .gitignore file that excludes IDE and Docusaurus build artifacts.
(repo-wide) · high confidence
Scala 3 macro implementation for GenIso, GenLens, and GenPrism
The Scala 3-specific macro implementations for \GenIso\, \GenLens\, and \GenPrism\ have been updated to align with the library's migration to the \Focus\ API. \GenIso\ now uses \Mirror\ types to generate \Iso\ instances, with \fields\ delegating to \IsoFields\ for multi-field cases, while \GenLens\ and \GenPrism\ are simplified to act as thin wrappers around \Focus\, ensuring consistent behavior with the newer API surface.
macro/src/main/scala-3 · high confidence
Standard library optics consolidated and expanded
The \monocle.std\ package has been reorganized into a single \All.scala\ aggregator that exposes a comprehensive set of standard library optics. This change introduces new typeclass instances and optics for Cats data structures (Chain, NonEmptyChain, NonEmptyList, NonEmptyVector, These, Validated) alongside existing Scala standard types (BigDecimal, BigInt, Byte, Char, Double, Either, Function, Int, List, Long, Map, Option, String, Try, Tuple1). Notable additions include prisms for parsing strings to numeric types and UUIDs/URIs, an \withDefault\ iso for Options, and specific logic to ensure string-to-numeric prisms respect Prism laws by rejecting invalid formats like negative zero.
core/shared/src/main/scala/monocle/std · high confidence
State module syntax is deprecated in version 3.0.0-M1
The \monocle.state\ module, which provided syntax to transform Monocle optics (such as Lenses, Optionals, Setters, and Traversals) into Cats \State\ actions, has been deprecated with no replacement. All syntax traits and extension methods in this module (including \StateLensSyntax\, \StateOptionalSyntax\, \StateGetterSyntax\, \StateSetterSyntax\, \StateTraversalSyntax\, and \ReaderGetterSyntax\) are now marked as deprecated since version 3.0.0-M1, signaling that users should migrate away from these state-based operations.
state · high confidence
Updated logo assets with new vector and print files
The logo directory now includes new editable vector source files (Adobe Illustrator .ai) and high-resolution PDF exports for both screen and print use. These assets replace previous versions, providing updated visual branding materials for the website and documentation.
logo · high confidence
Website migrated to Docusaurus with updated branding and landing page
The documentation site has been rebuilt using Docusaurus, replacing the previous microsite infrastructure. This change introduces a simplified landing page that highlights the new 'Focus' API for accessing and transforming immutable data, alongside updated installation instructions for Scala 2.13 and 3. The site now features a new visual identity with updated SVG branding assets, a custom footer component, and a reorganized sidebar structure that groups content into 'Optics' and 'Documentation' categories.
website · high confidence
Test coverage
Add JMH benchmarks for Iso, Lens, Prism, and Traversal; Added JVM-specific tests for URL Prisms; Added Scala 2-specific test suite for Monocle optics and generic instances; Added Scala 3 tests for Focus DSL and optic composition; Added Scala 3 tests for named tuple focus operations; Added comprehensive law-based tests for standard library optics; Added comprehensive test suite for Monocle optics; Added example tests for HTTP request and JSON AST manipulation; Added example tests for Monocle function optics; Added example tests for State module syntax; Added platform-specific test instances for Scala Native; Added test coverage for macro-generated optics and syntax features; Added test coverage for monocle function typeclasses; Added tests for UnsafeSelect; Added tests for std Option, These, and Validated optics; Added tests for symbolic optics composition syntax; New discipline test suites for Monocle optics.
Dependencies
Upgrade to Scala 3.9.0 and Cats 2.13.0 with Docusaurus documentation site
The build system has been updated to use Scala 3.9.0 and Scala 2.13.18, alongside upgrading the core Cats library dependency to version 2.13.0. The project now officially supports cross-compilation for JVM, JavaScript, and Native platforms using these versions. Additionally, the documentation infrastructure has migrated to Docusaurus, introducing a new \website\ directory with a \package.json\ that pins Docusaurus version 1.6.2 for generating and publishing the site.
(dependencies) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 53 → 51 (-2.0)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.
Lenses
- Code Health 75 → 69 (-6.3)
- Architecture 91 → 91 (+0.0)
- Maturity 40 → 41 (+0.1)
- Readiness 46 → 47 (+1.2)
- Security 79 → 65 (-13.9)
- Performance 88 → 85 (-3.0)
Resolved (2)
- Hotspot: core/shared/src/main/scala-3/monocle/internal/focus/features/ParserLoop.scala (core/shared/src/main/scala-3/monocle/internal/focus/features/ParserLoop.scala)
- Off-boarding risk: anonymized user #1
New (23)
- Edited copies of one member (3 members, 11+ corresponding lines) (core/shared/src/main/scala/monocle/function/FilterIndex.scala)
- Edited copies of one member (3 members, 12+ corresponding lines) (macro/src/main/scala-2/monocle/macros/syntax/AppliedFocusSyntax.scala)
- Edited copies of one member (3 members, 15+ corresponding lines) (core/shared/src/main/scala-3/monocle/internal/focus/features/at/AtParser.scala)
- Edited copies of one member (3 members, 5+ corresponding lines) (core/shared/src/main/scala/monocle/Iso.scala)
- Edited copies of one member (3 members, 5+ corresponding lines) (core/shared/src/main/scala/monocle/function/Cons1.scala)
- Edited copies of one member (3 members, 5+ corresponding lines) (core/shared/src/main/scala/monocle/function/Each.scala)
- Edited copies of one member (3 members, 5+ corresponding lines) (core/shared/src/main/scala/monocle/function/Reverse.scala)
- Edited copies of one member (3 members, 5+ corresponding lines) (core/shared/src/main/scala/monocle/function/Snoc1.scala)
- Edited copies of one member (3 members, 9+ corresponding lines) (bench/src/main/scala/monocle/bench/StdLensBench.scala)
- Edited copies of one member (4 members, 4+ corresponding lines) (core/shared/src/main/scala/monocle/Traversal.scala)
- Edited copies of one member (6 members, 3+ corresponding lines) (core/shared/src/main/scala/monocle/function/Field1.scala)
- Edited copy of a member (1 corresponding lines) (core/shared/src/main/scala/monocle/law/IsoLaws.scala)
- Edited copy of a member (16 corresponding lines) (core/shared/src/main/scala/monocle/Optional.scala)
- Edited copy of a member (18 corresponding lines) (core/shared/src/main/scala-3/monocle/internal/focus/features/selectfield/SelectFieldGenerator.scala)
- Edited copy of a member (4 corresponding lines) (core/shared/src/main/scala/monocle/law/OptionalLaws.scala)
- Edited copy of a member (5 corresponding lines) (core/shared/src/main/scala/monocle/Iso.scala)
- Edited copy of a member (5 corresponding lines) (core/shared/src/main/scala/monocle/Iso.scala)
- Edited copy of a member (6 corresponding lines) (core/shared/src/main/scala/monocle/function/Plated.scala)
- Edited copy of a member (7 corresponding lines) (core/shared/src/main/scala-3/monocle/internal/focus/features/as/AsGenerator.scala)
- Edited copy of a member (7 corresponding lines) (core/shared/src/main/scala-3/monocle/internal/focus/features/at/AtGenerator.scala)
- …and 3 more
Changes since last survey
- 1 commits — 1 feature/other, 0 fixes
By area
- project/build.properties — 1 commit
Notable commits
- change: Update sbt, scripted-plugin to 1.13.1
Architecture
- Unchanged — 0 containers · 1 contexts · 0 edges
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
optics-dev/Monocle was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 14 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit d1ce8664cd5091b31b950a8bfda20802ee9cf5e2 — the exact code this score is about.
- Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-36d4cd83012f.