{"id":25317345,"url":"https://github.com/xebia-functional/refine_types_scala3","last_synced_at":"2025-10-28T21:30:43.606Z","repository":{"id":199987773,"uuid":"704450493","full_name":"xebia-functional/refine_types_scala3","owner":"xebia-functional","description":"Repository that explores the possibilities of Scala 3 features of opaque types and inline for type refinement.","archived":false,"fork":false,"pushed_at":"2024-04-10T14:31:28.000Z","size":80,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-11T11:31:30.314Z","etag":null,"topics":["ddd","refinement-types","scala3"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xebia-functional.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-13T09:31:37.000Z","updated_at":"2024-04-11T11:31:30.315Z","dependencies_parsed_at":"2023-11-23T15:51:55.166Z","dependency_job_id":null,"html_url":"https://github.com/xebia-functional/refine_types_scala3","commit_stats":null,"previous_names":["dagmendez/opaque_types_and_inline"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xebia-functional%2Frefine_types_scala3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xebia-functional%2Frefine_types_scala3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xebia-functional%2Frefine_types_scala3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xebia-functional%2Frefine_types_scala3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xebia-functional","download_url":"https://codeload.github.com/xebia-functional/refine_types_scala3/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238722710,"owners_count":19519801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddd","refinement-types","scala3"],"created_at":"2025-02-13T19:37:24.479Z","updated_at":"2025-10-28T21:30:43.600Z","avatar_url":"https://github.com/xebia-functional.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Refined types in Scala 3\n\nThey way types are refined in Scala 3 is more performant than Scala 2. \nThanks to `opaque types` and new `metaprogramming` techniques, refined types in Scala 3 can be evaluated at compile time.\nIn situations where we do not know the value at compile time, `Either` wrappers around `error` or  `types` come handy to handle the validation process.\n\nThis repository contains various modules:\n- Language Feature: contains explanations in detail of how the Scala 3 metaprogramming techniques work to achieve \"free\" refined types.\n- Workshop: contains snippets of code that show the different trade-offs of multiple approaches to refining types\n- NeoType: Refines types without having to work with the Type System (Scala 3 only)\n- Iron: Refines types and has a robust type system framework (Scala 3 only)\n\n## Language Feature\n\nThis module contains multiple examples and explanations of the internal of Scala 3 while defining \"free\" refined types.\nCheck the [README.md](01-language-feature/README.md) of this module for a step bt step explanation.\n\nYou can check the blogpost [Crafting Concise Constructors with Opaque Types in Scala 3](https://xebia.com/blog/crafting-concise-constructors-opaque-types-scala-3/) were the code snippets were used as a source material.\n\n## Workshop\n\nContains code snippets that guide the audience towards the mechanics behind opaque types in Scala 3 and how to use them.\n\n# Dedicated Libraries\n\nThese 2 libraries work exclusively in Scala 3.\nBoth leverage the metaprogramming capabilities of Scala 3 in combination with a very strong a versatile type system.\nIf you would like to know the intuition behind how it works, check the blogpost [Generic Refinement Types in Scala 3](https://xebia.com/blog/generic-refinement-types-in-scala-3/).\n\n## NeoType\n\nThis module implements a validation for Spanish IDs.\n\nNeotype is a friendly newtype library for Scala 3.\nAllows you to define refinements using basic assertions in plain Scala.\n\n### Features\n\n- Compile-time Checked Values\n- Write validations as **plain, old Scala expressions**\n- Helpful compilation errors\n- No runtime allocations (Thanks to `inline` and `opaque type`)\n- Integrates with other libraries (e.g. `zio-json`, `circe`, `tapir`, etc.)\n\nMore information in the [library repository](https://github.com/kitlangton/neotype).\n\n## Iron\n\nThis module implements a validation for Spanish IDs.\nThe multiple implementations show the trade-offs of multiple approaches to refine types in a incremental way.\n\nIron is a lightweight library for refined types in Scala 3.\n\nIt enables attaching constraints/assertions (at the type level) to types, to enforce properties and forbid invalid values.\n\n### Features\n\n- Catch bugs. In the spirit of static typing, use more specific types to avoid invalid values.\n- Compile-time and runtime. Evaluate constraints at compile time, or explicitly check them at runtime (e.g. for a form).\n- Seamless. Iron types are subtypes of their unrefined versions, meaning you can easily add or remove them.\n- No black magic. Use Scala 3's powerful inline, types and restricted macros for consistent behaviour and rules. No unexpected behaviour.\n- Extendable. Easily create your own constraints or integrations using classic typeclasses.\n\nMore information in the [library repository](https://github.com/Iltotore/iron).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxebia-functional%2Frefine_types_scala3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxebia-functional%2Frefine_types_scala3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxebia-functional%2Frefine_types_scala3/lists"}