Optional typing in Clojure, as a library.
Usage Overview
tldr; see the minimal example project for Typed Clojure setup.
Typed Clojure is separated into modules. You'll want the full type checker at development time, and the runtime dependencies in production.
In Clojure CLI's deps.edn, this will look something like this:
{:deps {org.typedclojure/typed.clj.runtime {:mvn/version "1.3.0"}}
:aliases {:dev {:extra-deps {org.typedclojure/typed.clj.checker {:mvn/version "1.3.0"}}}}}You can then start a dev repl with clj -A:dev.
In Leiningen's project.clj, it will look something like this:
(defproject com.my-domain/a-project "1.0.0-SNAPSHOT" :dependencies [[org.typedclojure/typed.clj.runtime "1.3.0"]] :profiles {:dev {:dependencies [[org.typedclojure/typed.clj.checker "1.3.0"]]}})
Then, lein repl will automatically activate the :dev profile. Verify the type
checker is not included in uberjars with lein with-profile uberjar deps :tree.
Example projects
- minimal demonstrates how to statically type check Clojure namespaces
- minimal-clj demonstrates how to statically type check Clojure namespaces
- malli-type-providers demonstrates how to statically type check using malli schemas
- zero-deps demonstrates how to type check a library without introducing any runtime dependency on Typed Clojure (only dev-time).
- symbolic-guide shows how to reason about symbolic execution in Typed Clojure.
Releases and Dependency Information
Latest stable release is 1.3.0.
See modules for specific version coordinates:
Clojure implementation
- typed.clj.checker: The JVM type checker
- typed.clj.runtime: JVM Runtime dependencies
- typed.clj.analyzer: Analyzer for JVM Clojure
- typed.malli: Malli integration.
Implementation-agnostic
- typed.cljc.analyzer: Implementation-agnostic base for Clojure analyzers
Library Annotations
- typed.lib.clojure: Base type annotations
- typed.lib.core.async: Annotations for core.async
- typed.lib.spec.alpha: Annotations for spec.alpha
Compatibility
Typed Clojure supports Clojure 1.12.5 and JDK 21+.
Mailing List and Chat
Use the core.typed mailing list for Typed Clojure discussion.
#core-typed on Clojurians Slack
Documentation
See wiki.
Developer Information
Contributors
Thanks to the following people for contributing to core.typed:
- Stephen Compall (S11001001)
- Andrew Brehaut (brehaut)
- Christopher Spencer (cspencer)
- Reid McKenzie (arrdem)
- Di Xu (xudifsd)
- Nicola Mometto (Bronsa)
- Chas Emerick (cemerick)
- Jake Goulding (shepmaster)
- Andy Fingerhut
- Aravind K N (arav93)
- Allen Rohner (arohner)
- Minori Yamashita (ympbyc)
- Kyle Kingsbury (aphyr)
- Nathan Sorenson
- Tobias Kortkamp (t6)
- Alejandro Gomez (dialelo)
- Piotr Jarzemski (kazuhiro)
- Oleksandr Yakushev (alexander-yakushev)
- David Miller (dmiller)
License
Copyright © Ambrose Bonnaire-Sergeant, Rich Hickey & contributors.
Licensed under the EPL (see the file epl-v10.html).
tools.analyzer
Copyright © Nicola Mometto, Rich Hickey & contributors.
Licensed under the EPL (see the file epl-v10.html).
tools.analyzer.jvm
Copyright © Nicola Mometto, Rich Hickey & contributors.
Licensed under the EPL (see the file epl-v10.html).
tools.analyzer.js
Copyright © Nicola Mometto, Rich Hickey & contributors.
Licensed under the EPL (see the file epl-v10.html).