# fthomas/refined

Refinement types for Scala

Repository: https://github.com/fthomas/refined
Canonical: https://ross.abutalabs.com/products/refined
Language: Scala
License: MIT
License Family: permissive
Topics: refinement-types, scala, typelevel
Last push: 2026-08-23T17:59:34+00:00

## Health v2 (maintenance only)
Score: 85/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 58, longevity 100
- inputs: {"age_days": 4133, "days_push": 10, "days_rel": 64, "gap_med": 549, "n_releases_24m": 2}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1733, forks 153 (observed 2026-08-28T04:05:28.898423+00:00)

## What it is
refined is a Scala library for refinement types, letting you attach type-level predicates to base types so value constraints are checked at compile time (for literals) or runtime (for arbitrary values). It is a port of the Haskell refined library and includes inference rules for converting between compatible refined types.

## Use cases
- enforce that an Int is positive at compile time
- validate runtime values against predicates and get Either results
- constrain string values like non-empty or matching a regex via types
- convert between refined types when predicates imply each other
- catch invalid domain values as compile errors instead of runtime bugs

## When to choose
- you write Scala and want value constraints encoded in types
- you want compile-time validation of literals and safe conversions between constrained types
- you prefer typelevel-style functional programming idioms

## When to avoid
- you work outside the Scala/JVM ecosystem
- your team finds type-level predicates too complex for the codebase
- you need validation in dynamically typed languages

## Facets
- artifact type: library
- maturity: active
- function: type-system, form-handling
- domain: programming-languages, developer-tools
- platform: jvm
- tags: refinement-types, typelevel, scala, compile-time-validation, type-safety

## Member repositories
- fthomas/refined (main) score 85

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:28.898423+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:31:27.389371+00:00, confidence not recorded.
  - readme: https://github.com/fthomas/refined (fetched 2026-08-28T04:05:28.898423+00:00, sha 942373dcd846)
- Data as of 2026-08-30T08:39:29.467469+00:00.
