{"id":28624525,"url":"https://github.com/zio/zio-constraintless","last_synced_at":"2025-06-12T07:38:23.996Z","repository":{"id":64162997,"uuid":"513832332","full_name":"zio/zio-constraintless","owner":"zio","description":"An advanced library for building DSLs that allows defering the existence of type class instances until interpretation.","archived":false,"fork":false,"pushed_at":"2025-05-28T05:36:01.000Z","size":487,"stargazers_count":26,"open_issues_count":1,"forks_count":5,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-28T05:37:38.866Z","etag":null,"topics":["scala"],"latest_commit_sha":null,"homepage":"https://zio.dev/zio-constraintless","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-14T09:09:27.000Z","updated_at":"2025-05-28T05:35:30.000Z","dependencies_parsed_at":"2023-02-13T01:31:27.970Z","dependency_job_id":"ab4aba5d-0758-4133-b89f-bec0cf51a356","html_url":"https://github.com/zio/zio-constraintless","commit_stats":null,"previous_names":["zio-archive/zio-constraintless","zio/zio-constraintless"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/zio/zio-constraintless","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Fzio-constraintless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Fzio-constraintless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Fzio-constraintless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Fzio-constraintless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zio","download_url":"https://codeload.github.com/zio/zio-constraintless/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Fzio-constraintless/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259421444,"owners_count":22854810,"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":["scala"],"created_at":"2025-06-12T07:37:55.524Z","updated_at":"2025-06-12T07:38:23.987Z","avatar_url":"https://github.com/zio.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[//]: # (This file was autogenerated using `zio-sbt-website` plugin via `sbt generateReadme` command.)\n[//]: # (So please do not edit it manually. Instead, change \"docs/index.md\" file or sbt setting keys)\n[//]: # (e.g. \"readmeDocumentation\" and \"readmeSupport\".)\n\n# ZIO Constraintless\n\nZIO Constraintless allows you to build programs as mere descriptions with maximum polymorphism, maximum modularity, zero abstraction leakage, and zero casting.\n\n[![Development](https://img.shields.io/badge/Project%20Stage-Development-green.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-constraintless/workflows/Website/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-constraintless_2.13.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-constraintless_2.13/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-constraintless_2.13.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-constraintless_2.13/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-constraintless-docs_2.13/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-constraintless-docs_2.13) [![ZIO Constraintless](https://img.shields.io/github/stars/zio/zio-constraintless?style=social)](https://github.com/zio/zio-constraintless)\n\n## Introduction\n\nIt is **a Scala take on the following paper in Haskell, on parametrising the program with logical constraints at every node, without compromising modularity**\n\nhttp://www.doc.ic.ac.uk/~wlj05/files/Deconstraining.pdf\n\nAn excerpt from the paper:\n\n_\"The key principle that underpins our idea is that implementation- specific constraints should be imposed at the point of use of a data type, not at the point of definition, i.e. it embodies the established principle that an interface should be separated from its implementation(s).\"_\n\n## Installation\n\n```sbt\nlibraryDependencies += \"dev.zio\" %% \"constraintless\" % \"0.3.4\"\n```\n\n## Example \n\nExample: https://github.com/zio/zio-constraintless/blob/master/examples/src/main/scala/zio/constraintless/examples/Expr.scala\n\n## Context\n\nThe key to many inspectable programs such as an execution planner, a configuration DSL etc is the basic concept of \"programs as descriptions\", but this idea comes with limitations.\n\nThis description (or data) can easily turn out to be a Generalised ADT that can be recursive, such that compiler has to traverse through the unknown types (existential) and for the compiler to do any advanced/useful stuff with it, it needs to know more about these types.\n\nThe obvious implication of having to handle \"unknown\" is that, the data should hold on to informations as constraints (that are relevant to implementation) on types at the definition site. A possible solution is to compromise on parametric polymorphism, or fall back to relying unsafe/safe (relative) casting (asInstanceOf).\n\nThis naive approach imposes modularity issues, and possible runtime crashes. The reasonsing and solution is given in the above paper, and this project solves the exact problem in scala.\n\n## Why not the Hughes schema?\n\nIt doesn't allow you to have a compiler with multiple constraints.\n\nA few excerpts from the paper on why it doesn't work:\n\n```scala\nclass Typeable p a valueP :: a → p a\n```\n\n```scala\nnewtype SM a = SM {fromSM :: Int}\n\ninstance IntBool a ⇒ Typeable SM a where\n  valueP = SM · toInt\n```\n\n```scala\nnewtype Pretty a = Pretty {fromPretty :: String}\n\ninstance Show a ⇒ Typeable Pretty a where valueP = Pretty · show\n```\n\n```scala\ndata Exp p a where\nValueE::Typeable p a ⇒ a → Exp p a\n\nCondE ::Expp Bool→Exp p a → Exp p a → Exp p a \n\nEqE :: Eq a ⇒ Exp p a → Exp p a → Exp p Bool\n```\n\n```scala\npretty :: Exp Pretty a → String // works\ncompileSM :: Exp SM a → String // works\n```\n\nHowever, now suppose that we wish to apply the two functions to the same expression, as in:\n\n```scala\nf :: Exp p a → . . .\nf e = ...(compileSM e)...(pretty e)..\n```\n\nand that's impossible\n\n## Documentation\n\nLearn more on the [ZIO Constraintless homepage](https://zio.dev/zio-constraintless/)!\n\n## Contributing\n\nFor the general guidelines, see ZIO [contributor's guide](https://zio.dev/about/contributing).\n\n## Code of Conduct\n\nSee the [Code of Conduct](https://zio.dev/about/code-of-conduct)\n\n## Support\n\nCome chat with us on [![Badge-Discord]][Link-Discord].\n\n[Badge-Discord]: https://img.shields.io/discord/629491597070827530?logo=discord \"chat on discord\"\n[Link-Discord]: https://discord.gg/2ccFBr4 \"Discord\"\n\n## License\n\n[License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzio%2Fzio-constraintless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzio%2Fzio-constraintless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzio%2Fzio-constraintless/lists"}