From 2c423fb3daacaeb120b54a390c315588bba531a5 Mon Sep 17 00:00:00 2001 From: Ambrose Bonnaire-Sergeant Date: Wed, 10 Nov 2021 00:00:02 -0500 Subject: [PATCH] add lib.spec.alpha --- README.md | 1 + dev/resources/module-template/README.md | 2 +- dev/resources/module-template/deps.edn | 2 +- dev/resources/module-template/pom.xml | 2 +- dev/resources/root-templates/README.md | 1 + dev/resources/root-templates/pom.xml | 1 + .../root-templates/typed/clj.checker/deps.edn | 1 + .../root-templates/typed/clj.checker/pom.xml | 4 ++ .../typed/lib.spec.alpha/README.md | 60 +++++++++++++++++++ .../typed/lib.spec.alpha/deps.edn | 30 ++++++++++ .../typed/lib.spec.alpha/pom.xml | 25 ++++++++ dev/src/typed/dev/new_module.clj | 3 +- pom.xml | 1 + typed/clj.checker/deps.edn | 1 + typed/clj.checker/pom.xml | 4 ++ .../src/typed/clj/ext/clojure/core__doseq.clj | 2 - typed/lib.spec.alpha/README.md | 60 +++++++++++++++++++ typed/lib.spec.alpha/deps.edn | 30 ++++++++++ typed/lib.spec.alpha/pom.xml | 25 ++++++++ typed/lib.spec.alpha/script/gen-doc.sh | 3 + typed/lib.spec.alpha/script/gen_doc.clj | 10 ++++ typed/lib.spec.alpha/script/repl | 3 + typed/lib.spec.alpha/script/test | 3 + .../src/typed/ext/clojure/spec/alpha.clj | 37 ++++++++++++ .../src/typed/ext/clojure/spec/alpha__def.clj | 25 ++++++++ .../typed/ext/clojure/spec/alpha__fdef.clj | 24 ++++++++ .../ext/clojure/spec/alpha__def.clj | 12 ++++ .../ext/clojure/spec/alpha__fdef.clj | 12 ++++ 28 files changed, 378 insertions(+), 6 deletions(-) create mode 100644 dev/resources/root-templates/typed/lib.spec.alpha/README.md create mode 100644 dev/resources/root-templates/typed/lib.spec.alpha/deps.edn create mode 100644 dev/resources/root-templates/typed/lib.spec.alpha/pom.xml create mode 100644 typed/lib.spec.alpha/README.md create mode 100644 typed/lib.spec.alpha/deps.edn create mode 100644 typed/lib.spec.alpha/pom.xml create mode 100755 typed/lib.spec.alpha/script/gen-doc.sh create mode 100644 typed/lib.spec.alpha/script/gen_doc.clj create mode 100755 typed/lib.spec.alpha/script/repl create mode 100755 typed/lib.spec.alpha/script/test create mode 100644 typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha.clj create mode 100644 typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha__def.clj create mode 100644 typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha__fdef.clj create mode 100644 typed/lib.spec.alpha/test/typed_test/ext/clojure/spec/alpha__def.clj create mode 100644 typed/lib.spec.alpha/test/typed_test/ext/clojure/spec/alpha__fdef.clj diff --git a/README.md b/README.md index b5a205f4b..a6a834884 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ See modules for specific version coordinates: * [typed.lib.clojure](typed/lib.clojure/README.md): Base type annotations * [typed.lib.core.async](typed/lib.core.async/README.md): Annotations for core.async +* [typed.lib.spec.alpha](typed/lib.spec.alpha/README.md): Annotations for spec.alpha ## Compatibility diff --git a/dev/resources/module-template/README.md b/dev/resources/module-template/README.md index 4cbf2914f..dd37f5446 100644 --- a/dev/resources/module-template/README.md +++ b/dev/resources/module-template/README.md @@ -1,4 +1,4 @@ -{% do-not-edit-xml-comment %} +{&do-not-edit-xml-comment-template&} # {&module-artifact-id&} diff --git a/dev/resources/module-template/deps.edn b/dev/resources/module-template/deps.edn index 52fcb0074..be94daa58 100644 --- a/dev/resources/module-template/deps.edn +++ b/dev/resources/module-template/deps.edn @@ -1,4 +1,4 @@ -{&do-not-edit-comment-template&} +{&do-not-edit-edn-comment-template&} {:paths ["src"] :deps {org.clojure/clojure {:mvn/version "{◊clojure-mvn-version◊}"}} :mvn/repos {"sonatype-oss-public" diff --git a/dev/resources/module-template/pom.xml b/dev/resources/module-template/pom.xml index 81ebdbf8a..c48d67c32 100644 --- a/dev/resources/module-template/pom.xml +++ b/dev/resources/module-template/pom.xml @@ -1,5 +1,5 @@ -{% do-not-edit-xml-comment %} +{&do-not-edit-xml-comment-template&} 4.0.0 {◊typedclojure-group-id◊} diff --git a/dev/resources/root-templates/README.md b/dev/resources/root-templates/README.md index 6012582c6..74258737f 100644 --- a/dev/resources/root-templates/README.md +++ b/dev/resources/root-templates/README.md @@ -77,6 +77,7 @@ See modules for specific version coordinates: * [typed.lib.clojure](typed/lib.clojure/README.md): Base type annotations * [typed.lib.core.async](typed/lib.core.async/README.md): Annotations for core.async +* [typed.lib.spec.alpha](typed/lib.spec.alpha/README.md): Annotations for spec.alpha ## Compatibility diff --git a/dev/resources/root-templates/pom.xml b/dev/resources/root-templates/pom.xml index 5d29af53d..a26ec0213 100644 --- a/dev/resources/root-templates/pom.xml +++ b/dev/resources/root-templates/pom.xml @@ -167,6 +167,7 @@ typed/lib.clojure typed/lib.core.async + typed/lib.spec.alpha diff --git a/dev/resources/root-templates/typed/clj.checker/deps.edn b/dev/resources/root-templates/typed/clj.checker/deps.edn index 5f445a455..61d93ef88 100644 --- a/dev/resources/root-templates/typed/clj.checker/deps.edn +++ b/dev/resources/root-templates/typed/clj.checker/deps.edn @@ -6,6 +6,7 @@ {◊typedclojure-group-id◊}/typed.clj.analyzer {:local/root "../clj.analyzer" :deps/manifest :deps}, {◊typedclojure-group-id◊}/typed.clj.lang {:local/root "../clj.lang" :deps/manifest :deps}, {◊typedclojure-group-id◊}/typed.lib.clojure {:local/root "../lib.clojure" :deps/manifest :deps}, + {◊typedclojure-group-id◊}/typed.lib.spec.alpha {:local/root "../lib.spec.alpha" :deps/manifest :deps}, {◊typedclojure-group-id◊}/typed.clj.runtime {:local/root "../clj.runtime" :deps/manifest :deps}, org.clojure/math.combinatorics {:mvn/version "{◊math-combinatorics-mvn-version◊}", :exclusions [org.clojure/clojure]}, org.clojure/tools.namespace {:mvn/version "{◊tools-namespace-mvn-version◊}"}, diff --git a/dev/resources/root-templates/typed/clj.checker/pom.xml b/dev/resources/root-templates/typed/clj.checker/pom.xml index fcf306ce1..1537f5996 100644 --- a/dev/resources/root-templates/typed/clj.checker/pom.xml +++ b/dev/resources/root-templates/typed/clj.checker/pom.xml @@ -47,6 +47,10 @@ {◊typedclojure-group-id◊} typed.lib.clojure + + {◊typedclojure-group-id◊} + typed.lib.spec.alpha + org.clojure tools.namespace diff --git a/dev/resources/root-templates/typed/lib.spec.alpha/README.md b/dev/resources/root-templates/typed/lib.spec.alpha/README.md new file mode 100644 index 000000000..3db53ed42 --- /dev/null +++ b/dev/resources/root-templates/typed/lib.spec.alpha/README.md @@ -0,0 +1,60 @@ +{% do-not-edit-xml-comment %} +# typed.lib.spec.alpha + + + +

+ + +

+ +Annotations and type rules for spec.alpha. + +## Releases and Dependency Information + +Latest stable release is {◊typedclojure-stable-mvn-version◊}. + +* [All Released Versions](https://clojars.org/{◊typedclojure-group-id◊}/typed.lib.spec.alpha) + +[deps.edn](https://clojure.org/reference/deps_and_cli) JAR dependency information: + +```clj + {◊typedclojure-group-id◊}/typed.lib.spec.alpha {:mvn/version "{◊typedclojure-stable-mvn-version◊}"} +``` + +[deps.edn](https://clojure.org/reference/deps_and_cli) Git dependency information: + +- Note: use `clj -Sresolve` to resolve the `:tag` to a `:sha` + +```clj + {◊typedclojure-group-id◊}/typed.lib.spec.alpha + {:git/url "{◊typedclojure-git-https-url◊}" + :deps/root "typed/lib.spec.alpha" + :tag "{◊typedclojure-stable-mvn-version◊}"} +``` + +[Leiningen](https://github.com/technomancy/leiningen) dependency information: + +```clojure +[{◊typedclojure-group-id◊}/typed.lib.spec.alpha "{◊typedclojure-stable-mvn-version◊}"] +``` + +[Maven](https://maven.apache.org/) dependency information: + +```XML + + {◊typedclojure-group-id◊} + typed.lib.spec.alpha + {◊typedclojure-stable-mvn-version◊} + +``` + +## Documentation + +[API Reference](https://api.typedclojure.org/latest/typed.lib.spec.alpha/index.html) + +## License + +Copyright © Ambrose Bonnaire-Sergeant, Rich Hickey & contributors. + +Licensed under the EPL (see the file epl-v10.html). diff --git a/dev/resources/root-templates/typed/lib.spec.alpha/deps.edn b/dev/resources/root-templates/typed/lib.spec.alpha/deps.edn new file mode 100644 index 000000000..05f7617fb --- /dev/null +++ b/dev/resources/root-templates/typed/lib.spec.alpha/deps.edn @@ -0,0 +1,30 @@ +{% do-not-edit-edn-comment %} +{:paths ["src"] + :deps {org.clojure/clojure {:mvn/version "{◊clojure-mvn-version◊}"}} + :mvn/repos {"sonatype-oss-public" + {:url "{◊sonatype-oss-public-url◊}"}} + :aliases {:test + {:extra-deps {{◊typedclojure-group-id◊}/typed.clj.checker + {:local/root "../clj.checker" + :deps/manifest :deps}} + :extra-paths ["test"]} + :nREPL + {:extra-deps + {nrepl/nrepl {:mvn/version "{◊nrepl-mvn-version◊}"} + cider/cider-nrepl {:mvn/version "0.25.3"}}, + :main-opts ["-m" "nrepl.cmdline" + "--interactive" + "--middleware" "[\"cider.nrepl/cider-middleware\"]"]} + + :codox + {:extra-deps {codox/codox {:mvn/version "{◊codox-mvn-version◊}"}} + :extra-paths ["script"] + :main-opts ["-m" "gen-doc"]} + + :runner + {:extra-deps {{◊cognitect-test-runner-coordinates◊} + {:git/url "{◊cognitect-test-runner-git-url◊}" + :sha "{◊cognitect-test-runner-sha◊}"}} + :main-opts ["-m" "cognitect.test-runner" + "-d" "test" + "-r" ".*"]}}} diff --git a/dev/resources/root-templates/typed/lib.spec.alpha/pom.xml b/dev/resources/root-templates/typed/lib.spec.alpha/pom.xml new file mode 100644 index 000000000..cc139202b --- /dev/null +++ b/dev/resources/root-templates/typed/lib.spec.alpha/pom.xml @@ -0,0 +1,25 @@ + +{% do-not-edit-xml-comment %} + + 4.0.0 + {◊typedclojure-group-id◊} + typed.lib.spec.alpha + FIXME + typed.lib.spec.alpha + {◊typedclojure-current-mvn-version◊} + + + + Eclipse Public License 1.0 + http://opensource.org/licenses/eclipse-1.0.php + repo + + + + + {◊typedclojure-group-id◊} + pom.typed + {◊typedclojure-current-mvn-version◊} + ../.. + + diff --git a/dev/src/typed/dev/new_module.clj b/dev/src/typed/dev/new_module.clj index 59251d96a..ed78d7e7f 100644 --- a/dev/src/typed/dev/new_module.clj +++ b/dev/src/typed/dev/new_module.clj @@ -69,7 +69,8 @@ (su/set-missing-value-formatter! missing-value-fn) (let [artifact-id (first args) context-map (assoc (module-info artifact-id) - :do-not-edit-comment-template "{% do-not-edit-edn-comment %}")] + :do-not-edit-edn-comment-template "{% do-not-edit-edn-comment %}" + :do-not-edit-xml-comment-template "{% do-not-edit-xml-comment %}")] (doseq [[src dest] (create-template-plan artifact-id)] (io/make-parents (str "../" dest)) (spit (str "../" dest) diff --git a/pom.xml b/pom.xml index dc3b14838..046d41ad1 100644 --- a/pom.xml +++ b/pom.xml @@ -167,6 +167,7 @@ typed/lib.clojure typed/lib.core.async + typed/lib.spec.alpha diff --git a/typed/clj.checker/deps.edn b/typed/clj.checker/deps.edn index 0a3dffe73..30559339c 100644 --- a/typed/clj.checker/deps.edn +++ b/typed/clj.checker/deps.edn @@ -6,6 +6,7 @@ org.typedclojure/typed.clj.analyzer {:local/root "../clj.analyzer" :deps/manifest :deps}, org.typedclojure/typed.clj.lang {:local/root "../clj.lang" :deps/manifest :deps}, org.typedclojure/typed.lib.clojure {:local/root "../lib.clojure" :deps/manifest :deps}, + org.typedclojure/typed.lib.spec.alpha {:local/root "../lib.spec.alpha" :deps/manifest :deps}, org.typedclojure/typed.clj.runtime {:local/root "../clj.runtime" :deps/manifest :deps}, org.clojure/math.combinatorics {:mvn/version "0.1.6", :exclusions [org.clojure/clojure]}, org.clojure/tools.namespace {:mvn/version "1.1.0"}, diff --git a/typed/clj.checker/pom.xml b/typed/clj.checker/pom.xml index 1c2d9a4e4..32e529aa2 100644 --- a/typed/clj.checker/pom.xml +++ b/typed/clj.checker/pom.xml @@ -47,6 +47,10 @@ org.typedclojure typed.lib.clojure
+ + org.typedclojure + typed.lib.spec.alpha + org.clojure tools.namespace diff --git a/typed/lib.clojure/src/typed/clj/ext/clojure/core__doseq.clj b/typed/lib.clojure/src/typed/clj/ext/clojure/core__doseq.clj index 17968a824..ccb86b4e4 100644 --- a/typed/lib.clojure/src/typed/clj/ext/clojure/core__doseq.clj +++ b/typed/lib.clojure/src/typed/clj/ext/clojure/core__doseq.clj @@ -79,5 +79,3 @@ (r/ret r/-nil (fo/-false-filter)) expected)))))) - - diff --git a/typed/lib.spec.alpha/README.md b/typed/lib.spec.alpha/README.md new file mode 100644 index 000000000..f01f6c960 --- /dev/null +++ b/typed/lib.spec.alpha/README.md @@ -0,0 +1,60 @@ + +# typed.lib.spec.alpha + + + +

+ + +

+ +Annotations and type rules for spec.alpha. + +## Releases and Dependency Information + +Latest stable release is 1.0.19. + +* [All Released Versions](https://clojars.org/org.typedclojure/typed.lib.spec.alpha) + +[deps.edn](https://clojure.org/reference/deps_and_cli) JAR dependency information: + +```clj + org.typedclojure/typed.lib.spec.alpha {:mvn/version "1.0.19"} +``` + +[deps.edn](https://clojure.org/reference/deps_and_cli) Git dependency information: + +- Note: use `clj -Sresolve` to resolve the `:tag` to a `:sha` + +```clj + org.typedclojure/typed.lib.spec.alpha + {:git/url "https://github.com/typedclojure/typedclojure" + :deps/root "typed/lib.spec.alpha" + :tag "1.0.19"} +``` + +[Leiningen](https://github.com/technomancy/leiningen) dependency information: + +```clojure +[org.typedclojure/typed.lib.spec.alpha "1.0.19"] +``` + +[Maven](https://maven.apache.org/) dependency information: + +```XML + + org.typedclojure + typed.lib.spec.alpha + 1.0.19 + +``` + +## Documentation + +[API Reference](https://api.typedclojure.org/latest/typed.lib.spec.alpha/index.html) + +## License + +Copyright © Ambrose Bonnaire-Sergeant, Rich Hickey & contributors. + +Licensed under the EPL (see the file epl-v10.html). diff --git a/typed/lib.spec.alpha/deps.edn b/typed/lib.spec.alpha/deps.edn new file mode 100644 index 000000000..2ba1a1dbe --- /dev/null +++ b/typed/lib.spec.alpha/deps.edn @@ -0,0 +1,30 @@ +;; DO NOT EDIT! Instead, edit `dev/resources/root-templates/typed/lib.spec.alpha/deps.edn` and run `./script/regen-selmer.sh` +{:paths ["src"] + :deps {org.clojure/clojure {:mvn/version "1.10.3"}} + :mvn/repos {"sonatype-oss-public" + {:url "https://oss.sonatype.org/content/groups/public/"}} + :aliases {:test + {:extra-deps {org.typedclojure/typed.clj.checker + {:local/root "../clj.checker" + :deps/manifest :deps}} + :extra-paths ["test"]} + :nREPL + {:extra-deps + {nrepl/nrepl {:mvn/version "0.8.3"} + cider/cider-nrepl {:mvn/version "0.25.3"}}, + :main-opts ["-m" "nrepl.cmdline" + "--interactive" + "--middleware" "[\"cider.nrepl/cider-middleware\"]"]} + + :codox + {:extra-deps {codox/codox {:mvn/version "0.10.7"}} + :extra-paths ["script"] + :main-opts ["-m" "gen-doc"]} + + :runner + {:extra-deps {io.github.cognitect-labs/test-runner + {:git/url "https://github.com/cognitect-labs/test-runner" + :sha "4e7e1c0dfd5291fa2134df052443dc29695d8cbe"}} + :main-opts ["-m" "cognitect.test-runner" + "-d" "test" + "-r" ".*"]}}} diff --git a/typed/lib.spec.alpha/pom.xml b/typed/lib.spec.alpha/pom.xml new file mode 100644 index 000000000..e781be8a7 --- /dev/null +++ b/typed/lib.spec.alpha/pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + org.typedclojure + typed.lib.spec.alpha + FIXME + typed.lib.spec.alpha + 1.0.20-SNAPSHOT + + + + Eclipse Public License 1.0 + http://opensource.org/licenses/eclipse-1.0.php + repo + + + + + org.typedclojure + pom.typed + 1.0.20-SNAPSHOT + ../.. + + diff --git a/typed/lib.spec.alpha/script/gen-doc.sh b/typed/lib.spec.alpha/script/gen-doc.sh new file mode 100755 index 000000000..0266f1a2b --- /dev/null +++ b/typed/lib.spec.alpha/script/gen-doc.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +clojure -M:codox:test diff --git a/typed/lib.spec.alpha/script/gen_doc.clj b/typed/lib.spec.alpha/script/gen_doc.clj new file mode 100644 index 000000000..b7349b720 --- /dev/null +++ b/typed/lib.spec.alpha/script/gen_doc.clj @@ -0,0 +1,10 @@ +(ns gen-doc + (:require [codox.main :as codox])) + +(defn -main [& args] + (codox/generate-docs + {:language :clojure + :source-uri "https://github.com/typedclojure/typedclojure/blob/{git-commit}/typed.lib.spec.alpha/{filepath}#L{line}" + :output-path "target/codox"}) + (shutdown-agents) + (System/exit 0)) diff --git a/typed/lib.spec.alpha/script/repl b/typed/lib.spec.alpha/script/repl new file mode 100755 index 000000000..4a2d18cb1 --- /dev/null +++ b/typed/lib.spec.alpha/script/repl @@ -0,0 +1,3 @@ +#!/bin/sh + +clj -M:test:nREPL "$@" diff --git a/typed/lib.spec.alpha/script/test b/typed/lib.spec.alpha/script/test new file mode 100755 index 000000000..9bd45b2f0 --- /dev/null +++ b/typed/lib.spec.alpha/script/test @@ -0,0 +1,3 @@ +#!/bin/sh + +clojure "$@" -M:test:runner diff --git a/typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha.clj b/typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha.clj new file mode 100644 index 000000000..b7b85da6f --- /dev/null +++ b/typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha.clj @@ -0,0 +1,37 @@ +;; Copyright (c) Ambrose Bonnaire-Sergeant, Rich Hickey & contributors. +;; The use and distribution terms for this software are covered by the +;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +;; which can be found in the file epl-v10.html at the root of this distribution. +;; By using this software in any fashion, you are agreeing to be bound by +;; the terms of this license. +;; You must not remove this notice, or any other, from this software. + +(ns ^:no-doc typed.ext.clojure.spec.alpha + "Typing rules for spec.alpha." + (:require [typed.clj.checker.check :as chk])) + +(defmacro install-unanalyzed-special [v impl] + {:pre [(qualified-symbol? impl)]} + `(defmethod chk/-unanalyzed-special ~v + [expr# expected#] + ((requiring-resolve '~impl) expr# expected#))) + +(defmacro install-defuspecial [v impl] + {:pre [(qualified-symbol? impl)]} + `(chk/defuspecial ~v + [expr# expected#] + ((requiring-resolve '~impl) expr# expected#))) + +;;======================= +;; clojure.spec.alpha/def + +(install-defuspecial + 'clojure.spec.alpha/def + typed.ext.clojure.spec.alpha__def/defuspecial__def) + +;;======================= +;; clojure.spec.alpha/fdef + +(install-defuspecial + 'clojure.spec.alpha/fdef + typed.ext.clojure.spec.alpha__fdef/defuspecial__fdef) diff --git a/typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha__def.clj b/typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha__def.clj new file mode 100644 index 000000000..0dbd5b40b --- /dev/null +++ b/typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha__def.clj @@ -0,0 +1,25 @@ +;; Copyright (c) Ambrose Bonnaire-Sergeant, Rich Hickey & contributors. +;; The use and distribution terms for this software are covered by the +;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +;; which can be found in the file epl-v10.html at the root of this distribution. +;; By using this software in any fashion, you are agreeing to be bound by +;; the terms of this license. +;; You must not remove this notice, or any other, from this software. + +(ns ^:no-doc typed.ext.clojure.spec.alpha__def + "Typing rules for clojure.spec.alpha/def." + (:require [clojure.core.typed :as t] + [typed.cljc.checker.check-below :as below] + [typed.cljc.checker.filter-ops :as fo] + [typed.cljc.checker.filter-rep :as fl] + [typed.cljc.checker.type-rep :as r] + [typed.cljc.checker.utils :as u])) + +(defn defuspecial__def + "defuspecial implementation for clojure.spec.alpha/def" + [expr expected] + (-> expr + (assoc + u/expr-type (below/maybe-check-below + (r/ret r/-any) + expected)))) diff --git a/typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha__fdef.clj b/typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha__fdef.clj new file mode 100644 index 000000000..27d19ef68 --- /dev/null +++ b/typed/lib.spec.alpha/src/typed/ext/clojure/spec/alpha__fdef.clj @@ -0,0 +1,24 @@ +;; Copyright (c) Ambrose Bonnaire-Sergeant, Rich Hickey & contributors. +;; The use and distribution terms for this software are covered by the +;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +;; which can be found in the file epl-v10.html at the root of this distribution. +;; By using this software in any fashion, you are agreeing to be bound by +;; the terms of this license. +;; You must not remove this notice, or any other, from this software. + +(ns ^:no-doc typed.ext.clojure.spec.alpha__fdef + "Typing rules for clojure.spec.alpha/fdef." + (:require [typed.cljc.checker.check-below :as below] + [typed.cljc.checker.filter-ops :as fo] + [typed.cljc.checker.filter-rep :as fl] + [typed.cljc.checker.type-rep :as r] + [typed.cljc.checker.utils :as u])) + +(defn defuspecial__fdef + "defuspecial implementation for clojure.spec.alpha/fdef" + [expr expected] + (-> expr + (assoc + u/expr-type (below/maybe-check-below + (r/ret r/-any) + expected)))) diff --git a/typed/lib.spec.alpha/test/typed_test/ext/clojure/spec/alpha__def.clj b/typed/lib.spec.alpha/test/typed_test/ext/clojure/spec/alpha__def.clj new file mode 100644 index 000000000..3777ccb75 --- /dev/null +++ b/typed/lib.spec.alpha/test/typed_test/ext/clojure/spec/alpha__def.clj @@ -0,0 +1,12 @@ +(ns ^:no-doc typed-test.ext.clojure.spec.alpha__def + (:require [clojure.test :refer [deftest is testing]] + typed.ext.clojure.spec.alpha + [clojure.core.typed :as t] + [typed.clj.checker.parse-unparse :as prs] + [clojure.core.typed.test.test-utils :refer :all])) + +(deftest sdef-test + (is-tc-e (s/def :foo/bar int?) + :requires [[clojure.spec.alpha :as s]]) + (is-tc-err (ann-form (s/def :foo/bar int?) nil) + :requires [[clojure.spec.alpha :as s]])) diff --git a/typed/lib.spec.alpha/test/typed_test/ext/clojure/spec/alpha__fdef.clj b/typed/lib.spec.alpha/test/typed_test/ext/clojure/spec/alpha__fdef.clj new file mode 100644 index 000000000..b1bd6c61c --- /dev/null +++ b/typed/lib.spec.alpha/test/typed_test/ext/clojure/spec/alpha__fdef.clj @@ -0,0 +1,12 @@ +(ns ^:no-doc typed-test.ext.clojure.spec.alpha__fdef + (:require [clojure.test :refer [deftest is testing]] + typed.ext.clojure.spec.alpha + [clojure.core.typed :as t] + [typed.clj.checker.parse-unparse :as prs] + [clojure.core.typed.test.test-utils :refer :all])) + +(deftest fdef-test + (is-tc-e (s/fdef bar :args (s/cat)) + :requires [[clojure.spec.alpha :as s]]) + (is-tc-err (ann-form (s/fdef bar :args (s/cat)) nil) + :requires [[clojure.spec.alpha :as s]]))