fthomas/refined
59.3
Adequate · 14 November 2026
5.6k
lines of production code
Scala
primary language
7
measurements over time
What this system is
Features
Add JMH benchmark suite for Refined performance measurement
A new benchmark module has been added to the project, introducing JMH-based performance tests for key Refined operations. This includes benchmarks for macro inference (autoInfer), type refinement (autoRefineV), unsafe value creation (PosInt.unsafeFrom), and validated refinement (refineV) for both numeric and string types. The benchmarks are configured to measure average execution time in nanoseconds, providing a baseline for tracking performance improvements in macro expansion and runtime validation.
modules/benchmark · high confidence
Add Pureconfig integration for Scala 3
This change introduces support for the Pureconfig library in Scala 3 by moving the integration code to a shared module and providing version-specific implementations. For Scala 3, it uses Scala 3 macros to describe types, while Scala 2 continues to use reflection-based type tags. This enables users to read and write refined types from configuration files in Scala 3 projects.
modules/pureconfig/shared/src/main · high confidence
Add scodec integration for refined types
This change introduces a new \scodec\ module that integrates the refined library with the scodec codec framework. It provides a \RefTypeCodec\ instance, allowing users to encode and decode refined types (such as \PosInt\) directly, where decoding automatically validates the predicate and fails if the value does not satisfy the constraint. Additionally, it adds specific validation support for \ByteVector\ size predicates, enabling refined checks on the length of byte vectors during validation.
modules/scodec · high confidence
Add scopt module for refined type parsing
A new \scopt\ module has been added to provide seamless integration between the refined library and the scopt command-line parser. This module supplies an implicit \Read\ instance for refined types, allowing users to define scopt options that automatically validate input against refined predicates. If a parsed value fails validation, the parser will reject it, ensuring that configuration objects only contain valid data.
modules/scopt · high confidence
Add string utility module for validated type construction
A new \string\ utility module has been added to \eu.timepit.refined.util\, providing factory methods to construct \Regex\, \URI\, \URL\, \UUID\, and \XPathExpression\ instances from strings validated by refined types. This allows users to safely instantiate these standard library types using statically checked string constraints.
modules/core/shared/src/main/scala/eu/timepit/refined/util · high confidence
Added JSON path validation for strings
Users can now validate that a String contains a syntactically correct JSON path using the new \JSONPath\ refinement type in the \eu.timepit.refined.jsonpath\ package. This feature leverages the \com.jayway.jsonpath\ library to compile and verify path expressions, ensuring that strings conform to valid JSON path syntax before being used in refined contexts.
modules/jsonpath · high confidence
Adds Scalaz integration with automatic typeclass derivation
This change introduces a new Scalaz module providing seamless integration between Refined and Scalaz. It adds a \RefType\ implementation for Scalaz's \@@\ tag type, enabling automatic refinement via the \auto\ object. The module includes a \derivation\ object that automatically generates typeclass instances (such as \Equal\ and \Show\) for refined types by leveraging Scalaz's \Contravariant\ and \MonadError\ capabilities. Additionally, it provides syntax helpers for validating refined types against Scalaz's \ValidationNel\ error handling, while deprecating the previous generic derivation methods in favor of this new organized structure.
modules/scalaz/shared/src/main · high confidence
Compile-time refinement for BigInt and BigDecimal literals
The Scala 3.0- macro implementation now supports compile-time validation for \BigInt\ and \BigDecimal\ literal values. By introducing \BigIntMatcher\ and \BigDecimalMatcher\ utilities and caching validation instances for these types, the library can now refine these numeric types at compile time, preventing runtime errors for invalid constants just as it does for standard numeric types like \Int\ and \Double\.
modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/macros · high confidence
Expanded Cats integration with derivation, syntax, and numeric instances
The Cats module now provides comprehensive support for Cats typeclasses and syntax. It introduces generic derivation instances (via \Contravariant\ and \MonadError\) for encoding/decoding refined types, and adds \Eq\, \Order\, and \Show\ instances for refined types. New syntax extensions allow validating refined types into \ValidatedNel\/\ValidatedNec\ and provide \take\ operations for \NonEmptyList\ and \NonEmptyVector\. Additionally, commutative semigroup and monoid instances are added for positive/negative numeric refined types, handling overflow by shifting values, and an \UnorderedFoldable\ instance is provided to validate collection sizes.
modules/cats/shared/src/main · high confidence
Introduce runtime expression evaluation for refined predicates
Users can now define validation predicates using string-based Scala expressions that are evaluated at runtime via the Scala ToolBox. This change adds an \Eval\ type and corresponding \Validate\ instance in the \modules/eval\ module, allowing predicates like \Eval\[W.\"(x: Int) =\> x % 2 == 0"\.T\]\ to be used with refined types. The implementation caches the ToolBox instance for performance and includes tests verifying correct evaluation of expressions, proper handling of parameter types, and appropriate error throwing for out-of-scope variables.
modules/eval · high confidence
New Char validation predicates added
The library now includes a new \char\ module providing validation predicates for \Char\ values, specifically \Digit\, \Letter\, \LowerCase\, \UpperCase\, and \Whitespace\, along with a combined \LetterOrDigit\ type alias. Users can now refine \Char\ types using these built-in validators to enforce character classification constraints.
modules/core/shared/src/main/scala/eu/timepit/refined · high confidence
New predefined refined types for characters, numbers, and more
The \eu.timepit.refined.types\ package now provides a comprehensive set of predefined refined types, organized into specific modules. Users can now import \Char\ types like \LowerCaseChar\ and \UpperCaseChar\, as well as a wide range of numeric types including \PosInt\, \NonNegLong\, \NegDouble\, and \NonNaNFloat\/\NonNaNDouble\. These types are also aggregated in the \all\ module for convenient bulk imports, simplifying the use of common refined constraints without needing to define them manually.
modules/core/shared/src/main/scala/eu/timepit/refined/types · high confidence
New refined types for digests, networking, strings, and time
The \eu.timepit.refined.types\ package now exposes new type aliases and companion objects for message digests (MD5, SHA1, SHA224, SHA256, SHA384, SHA512), network identifiers (port numbers, RFC1918/RFC5737/RFC3927 private and test networks), string constraints (finite, non-empty, trimmed, hex), and time units (month, day, hour, minute, second, millisecond). These types are available in the \scala-3.0-\ source directory and provide compile-time validation for these common data categories.
modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/types · high confidence
New refined types for network, string, time, and digest validation
The Scala 3 source directory now includes dedicated modules for network, string, time, and digest types. Users can validate port numbers (including system, user, and dynamic ranges) and IPv4 addresses against RFC1918, RFC5737, and RFC3927 standards. String validation now supports finite lengths with optional truncation, non-empty checks, trimming, and hexadecimal formatting. Time components (month, day, hour, minute, second, millisecond) are enforced via numeric intervals, and message digests (MD5, SHA1, SHA224, SHA256, SHA384, SHA512) are validated by length and hexadecimal format.
modules/core/shared/src/main/scala-3.0+/eu/timepit/refined/types · high confidence
Project initialization and configuration setup
The repository has been initialized with the refined library (version 0.11.4), including the core source code, comprehensive documentation in README.md, and the MIT license. Build and development tooling has been configured via .scalafmt.conf (version 3.11.5), .jvmopts, and .scala-steward.conf. CI/CD infrastructure has been set up using GitHub Actions (replacing the previous Travis CI configuration) and Mergify for automated pull request handling, while code coverage is enabled via .codecov.yml.
(repo-wide) · high confidence
Refined API core types and validation logic
The refined library's core API now explicitly defines the foundational type classes and structures used for refinement. This includes the \Validate\ type class for checking predicates, the \Result\ sealed trait (with \Passed\ and \Failed\ cases) for validation outcomes, and the \Inference\ type class for handling refinement subtyping. Additionally, new \Min\ and \Max\ type classes are introduced to determine the minimum and maximum valid values for refined types, supporting various numeric bounds and logical combinations. The \RefinedType\ trait is also defined to combine \RefType\ and \Validate\ instances, providing methods like \refine\ and \unsafeRefine\ for creating refined values.
modules/core/shared/src/main/scala/eu/timepit/refined/api · high confidence
Refined core predicates and auto-refinement support for Scala 2
This change introduces the core refined library implementation for Scala 2 (via the \scala-3.0-\ source directory), providing compile-time validation and automatic refinement capabilities. It defines predicates for boolean logic (And, Or, Not), numeric comparisons (Greater, Less, Interval), collection properties (Size, Forall, NonEmpty), and string formats (IPv4, IPv6, Regex, Uri). It also includes \auto.scala\, which enables implicit compile-time refinements and type conversions, allowing values to be automatically wrapped in refined types or converted between compatible refined types when valid.
modules/core/shared/src/main/scala-3.0-/eu/timepit/refined · high confidence
Support for Shapeless Typeable on refined types
The shapeless module now provides an implicit Typeable instance for refined types, allowing refined values to be cast and described via Shapeless's Typeable interface. This enables runtime type checking and casting for refined types (e.g., PosInt, String with regex constraints) by validating the underlying value against the refinement predicate during the cast operation. A corresponding test suite verifies successful casts, failed casts when refinements are violated, and the descriptive string output for these types.
modules/shapeless · high confidence
Removals
Removal of core refined validation types and combinators
The \refined\ package's foundational validation infrastructure has been removed, including the \Predicate\ trait, the \refine\ and \refineL\ entry-point functions, and all built-in predicate implementations for boolean logic (\Not\, \And\, \Or\), numeric comparisons (\Less\, \Greater\, \Positive\, \Negative\), and string constraints (\NonEmpty\, \LowerCase\, \UpperCase\). Users can no longer use these types to validate or refine values within this module.
src/main · high confidence
Behavioural changes
Historical download statistics added for 2016–2018
The \data/downloads\ directory now contains monthly CSV files covering download counts and proportions for Scala versions 2.10, 2.11, and 2.12 from June 2016 through June 2018. Each file lists version-specific download volumes, providing a detailed historical record of library adoption over this period.
data · high confidence
Internal refactoring of type inference helpers and error messaging
The internal implementation of refined has been reorganized to improve code structure and maintainability. New internal files have been introduced: \Adjacent.scala\ provides a type class for finding the next greater or smaller value for numeric types, extending \Ordering\; \ApplyRefPartiallyApplied.scala\ and \RefinePartiallyApplied.scala\ contain helper classes to support Scala's type inference for refinement operations; and \Resources.scala\ centralizes string constants and formatting logic for validation error messages. These changes affect the internal mechanics of how refinements are applied and how errors are reported, but do not alter the public API surface.
modules/core/shared/src/main/scala/eu/timepit/refined/internal · high confidence
New predicates package with unified import and binary compatibility fixes
The library introduces a new \eu.timepit.refined.predicates\ package that consolidates all predicate types (boolean, char, collection, generic, numeric, and string) into a single \all\ object for easier importing. This change reorganizes existing predicates into specific sub-packages (e.g., \boolean\, \numeric\) while maintaining binary compatibility through separate traits (\AllPredicatesBinCompat1\, \NumericPredicatesBinCompat1\). Notably, the \NonNaN\ numeric predicate and \HexStringSpec\ string predicate are now explicitly included in these compatibility layers to ensure existing code continues to work without recompilation.
modules/core/shared/src/main/scala/eu/timepit/refined/predicates · high confidence
New release script replaces sbt-release
The project now uses a custom shell script (scripts/release.sh) to manage releases, replacing the previous sbt-release plugin. This script automates the process of updating version numbers in the README and build configuration, creating signed git tags, and pushing changes, while also allowing the old version to be passed as a parameter.
scripts · high confidence
RefType and RefinedTypeOps API restructured for Scala 3 compatibility
The core refinement API in the \scala-3.0-\ source directory has been restructured to support Scala 3 (Dotty) while maintaining Scala 2 compatibility. \RefType\ now provides a cleaner trait-based interface for wrapping and unwrapping refined types, removing the use of existential types in \unwrap\ to resolve compiler errors. \Refined\ is defined as a simple value class, and \RefinedTypeOps\ offers a simplified way to create companion objects for refined types with methods like \from\, \unsafeFrom\, and \unapply\. Deprecated macro-based methods (\unsafeWrapM\, \unsafeRewrapM\, \refineMF\) are retained but marked for removal, encouraging migration to the new non-macro variants.
modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/api · high confidence
Refactored ScalaCheck integration to support Scala 3 and modernized numeric predicates
The scalacheck module has been restructured to provide ScalaCheck Arbitrary instances for refined types, with separate source files for Scala 2 and Scala 3 to handle type-class differences (e.g., using \ValueOf\ in Scala 3 vs \Witness\ in Scala 2). This update introduces comprehensive generators for string predicates (such as \NonEmpty\, \Size\, and numeric string validations), collection predicates (including \NonEmpty\ and \Size\ for Lists and Vectors), and logical predicates (like \Or\). Numeric generation has been modernized to use the \Min\ and \Max\ API instead of the deprecated \Bounded\ type class, and the internal \Adjacent\ utility has been deprecated in favor of the core module's implementation. A generic \Arbitrary\ instance for any refined type is also provided, though it may discard invalid values during generation.
modules/scalacheck/shared/src/main · high confidence
Scala 3 support via opaque types and RefType abstraction
The library now supports Scala 3 by introducing a new \RefType\ type class that abstracts refinement operations (wrap, unwrap, refine) and providing a Scala 3-specific implementation of \Refined\ as an opaque type. This change replaces the previous Scala 2 implementation (which relied on shapeless) with native Scala 3 features, including an infix syntax for the \Refined\ type alias and extension methods for value access. Additionally, \RefinedTypeOps\ is provided to simplify the creation of companion objects for refined types, offering \from\ and \unsafeFrom\ methods.
modules/core/shared/src/main/scala-3.0+/eu/timepit/refined/api · high confidence
Scala 3 support with native type inference and infix syntax
The refined library now provides a dedicated source set for Scala 3 (scala-3.0+) that replaces the previous shapeless-based implementation with native Scala 3 features. This change introduces automatic refinement unwrapping via the \auto\ module, allowing refined types to be used as subtypes of their base types without explicit conversion. It also adds compile-time type inference for predicates (e.g., inferring \Greater\[5\]\ implies \GreaterEqual\[5\]\) and enables infix syntax for boolean operators (\And\, \Or\, \Xor\) and numeric comparisons, improving code readability. Additionally, it allows Int and Double literals to be used directly as arguments in predicates, simplifying the definition of numeric constraints.
modules/core/shared/src/main/scala-3.0+/eu/timepit/refined · high confidence
Support for Int and Double literals in numeric predicates (Scala 3.0-)
For users on Scala versions prior to 3.0, the library now allows Int and Double literals to be used directly as universal arguments in numeric predicates (e.g., \Greater\[W.\2.718\.T\]\ or \Less\[W.\1\.T\]\). This is achieved by introducing the \WitnessAs\ type class in the \scala-3.0-\ source directory, which provides implicit conversions from literal types to various numeric base types (Byte, Short, Int, Long, Float, Double, BigDecimal, BigInt). This change enables more concise and intuitive predicate definitions without requiring explicit type annotations or wrapper conversions for common numeric literals.
modules/core/shared/src/main/scala-3.0-/eu/timepit/refined/internal · high confidence
Support for Int and Double literals in numeric predicates via Scala 3 inline implicits
The library now allows Int and Double literals to be used directly as arguments in numeric predicates (such as Greater or Less) when running on Scala 3. This is achieved by introducing a new ToInt type class and replacing the deprecated generic intWitnessAs with specialized inline given instances (e.g., intWitnessAsByte, intWitnessAsDouble) that convert integer literals to the target numeric type at compile time. This change removes the dependency on shapeless for Scala 3 and enables seamless usage like refineV\[Greater\[2.718\]\](BigDecimal(3.141)).
modules/core/shared/src/main/scala-3.0+/eu/timepit/refined/internal · high confidence
Test coverage
Added JVM-specific validation tests for String types; Added Scala 3 test suite for core refined predicates and inference; Added ScalaCheck property tests for refined types; Added comprehensive test coverage for Cats integration; Added comprehensive test coverage for refined types; Added test coverage for auto-unwrap and character validation; Added tests for Cogen instances and NonEmptyString generation; Added tests for RefinedTypeOps; Added tests for Scalaz integration; Added tests for numeric validation refinements in Scala 3; Added tests for refined type configuration conversion; Added tests for scalaz imports and NonEmptyString.show; Added tests for string type refinements and hash validations.
Dependencies
Major build system overhaul and dependency updates
The build configuration has been significantly modernized, introducing centralized version management for key libraries including Cats (2.13.0), PureConfig (0.17.8), Shapeless (2.3.13), and ScalaCheck (1.20.0). The project now officially supports cross-compilation for Scala 2.12, 2.13, and Scala 3 across JVM, JavaScript, and Native platforms, with specific modules like \cats\, \core\, \scalacheck\, and \shapeless\ available on all three targets. Additionally, the build integrates GitHub Actions for CI/CD, Mergify for automated PR handling, and Codecov for coverage reporting, replacing previous CI setups.
(dependencies) · high confidence
Upgrade to sbt 1.13.0 and consolidate build plugins
The build system has been upgraded from sbt 0.13.8 to sbt 1.13.0. This change consolidates previously separate plugin configuration files (plugin-bintray.sbt, plugin-git.sbt, plugin-scalariform.sbt) into a single plugins.sbt file, removing the deprecated bintray and scalariform plugins in favor of sbt-ci-release, sbt-git, and sbt-scalafmt. A new LatestVersion.scala plugin is introduced to manage versioning metadata, and all core build plugins (Scala.js, Scala Native, scoverage, doctest, etc.) are updated to their latest compatible versions.
project · 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 61 → 59 (-1.7)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.
Lenses
- Code Health 75 → 70 (-4.8)
- Architecture 87 → 95 (+8.0)
- Maturity 59 → 59 (-0.0)
- Readiness 53 → 51 (-1.8)
- Security 79 → 65 (-13.9)
- Performance 73 → 90 (+16.6)
Resolved (3)
- Duplicated block (6 lines × 2) (modules/core/shared/src/main/scala-3.0+/eu/timepit/refined/boolean.scala)
- Off-boarding risk: anonymized user #1
- Projects may be oversized for their cohesion
New (3)
- Edited copy of a member (17 corresponding lines) (modules/cats/shared/src/main/scala/eu/timepit/refined/cats/unorderedFoldable.scala)
- Edited copy of a member (8 corresponding lines) (modules/cats/shared/src/main/scala/eu/timepit/refined/cats/package.scala)
- Off-boarding risk: anonymized user #1
Changes since last survey
- 6 commits — 6 feature/other, 0 fixes
By area
- (repo) — 3 commits
- (root) — 1 commit
- project/build.properties — 1 commit
- project/plugins.sbt — 1 commit
Notable commits
- change: Merge pull request #1484 from scala-steward/update/scala3-library-3.3.9
- change: Merge pull request #1485 from scala-steward/update/sbt-1.13.1
- change: Merge pull request #1487 from scala-steward/update/doctest-runtime-0.13.3
- change: Update doctest-runtime, sbt-doctest to 0.13.3
- change: Update sbt, scripted-plugin to 1.13.1
- change: Update scala3-library, ... to 3.3.9
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
fthomas/refined 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 2d9cd42102e2936a725e7bdcea254883d533dab8 — 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.