{"id":19917188,"url":"https://github.com/athos/specium","last_synced_at":"2025-10-10T15:48:55.900Z","repository":{"id":62434682,"uuid":"96387896","full_name":"athos/specium","owner":"athos","description":"Inverse of s/form, reducing eval calls as much as possible","archived":false,"fork":false,"pushed_at":"2017-12-10T11:27:05.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T15:57:53.540Z","etag":null,"topics":["clojure","clojure-spec","clojurescript","spec"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/athos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-06T04:20:59.000Z","updated_at":"2018-10-13T18:22:36.000Z","dependencies_parsed_at":"2022-11-01T21:02:20.284Z","dependency_job_id":null,"html_url":"https://github.com/athos/specium","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/athos/specium","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Fspecium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Fspecium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Fspecium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Fspecium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/athos","download_url":"https://codeload.github.com/athos/specium/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Fspecium/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003169,"owners_count":26083533,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["clojure","clojure-spec","clojurescript","spec"],"created_at":"2024-11-12T21:49:05.975Z","updated_at":"2025-10-10T15:48:55.871Z","avatar_url":"https://github.com/athos.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# specium\n[![Clojars Project](https://img.shields.io/clojars/v/specium.svg)](https://clojars.org/specium)\n[![CircleCI](https://circleci.com/gh/athos/specium/tree/master.svg?style=shield)](https://circleci.com/gh/athos/specium/tree/master)\n[![codecov](https://codecov.io/gh/athos/specium/branch/master/graph/badge.svg)](https://codecov.io/gh/athos/specium)\n\nSpecium provides the inverse function of `clojure.spec(.alpha)/form`, reducing `eval` calls as much as possible.\n\n## Installation\n\nAdd the following to your `:dependencies`:\n\n[![Clojars Project](https://clojars.org/specium/latest-version.svg)](http://clojars.org/specium)\n\n## Usage\n\nA common way of getting a `s/form`ed spec form back into a spec object is to call `eval` with it:\n\n```clj\n=\u003e (s/form (s/map-of keyword? integer?))\n(clojure.spec.alpha/map-of clojure.core/keyword? clojure.core/integer?)\n=\u003e (eval *1)\n#object[clojure.spec.alpha$every_impl$reify__946 0x6d47d0b2 \"clojure.spec.alpha$every_impl$reify__946@6d47d0b2\"]\n=\u003e (s/conform *1 {:key \"wrong value\"})\n:clojure.spec.alpha/invalid\n=\u003e (s/explain *2 {:key \"wrong value\"})\nIn: [:key 1] val: \"wrong value\" fails at: [1] predicate: integer?\n:clojure.spec.alpha/spec  #object[clojure.spec.alpha$every_impl$reify__946 0x6d47d0b2 \"clojure.spec.alpha$every_impl$reify__946@6d47d0b2\"]\n:clojure.spec.alpha/value  {:key \"wrong value\"}\nnil\n=\u003e \n```\n\nThough it perfectly works, in some cases you might not be able to overlook `eval`'s inefficiency (eg. where lots of spec forms have to be dealt with).\n\n_Specium_ provides the `-\u003espec` fn, which can be used as the inverse function of `s/form`; that is, you can use it to get spec forms back to spec objects efficiently, almost without calling `eval`:\n\n```clj\n=\u003e (require '[specium.core :as specium])\nnil\n=\u003e (s/form (s/map-of keyword? integer?))\n(clojure.spec.alpha/map-of clojure.core/keyword? clojure.core/integer?)\n=\u003e (def s (specium/-\u003espec *1))\n#'user/s\n=\u003e (s/conform s {:key \"wrong value\"})\n:clojure.spec.alpha/invalid\n=\u003e (s/explain s {:key \"wrong value\"})\nIn: [:key 1] val: \"wrong value\" fails at: [1] predicate: integer?\n:clojure.spec.alpha/spec  #object[clojure.spec.alpha$every_impl$reify__946 0x581fa0b \"clojure.spec.alpha$every_impl$reify__946@581fa0b\"]\n:clojure.spec.alpha/value  {:key \"wrong value\"}\nnil\n=\u003e\n```\n\nNote that we said \"**almost** without calling `eval`\", which means that `eval` is actually necessary in some cases, especially in the case the spec form has an `fn` form in it as a predicate.\n\n## License\n\nCopyright © 2017 Shogo Ohta\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathos%2Fspecium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fathos%2Fspecium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathos%2Fspecium/lists"}