An optional type system for Clojure
Clojure Other
Switch branches/tags
core.typed-pom-0.5.3 core.typed-pom-0.5.2 core.typed-pom-0.5.1 core.typed-pom-0.5.0 core.typed-pom-0.4.3 core.typed-pom-0.4.2 core.typed-pom-0.4.1 core.typed-pom-0.4.0 core.typed-pom-0.3.32 core.typed-pom-0.3.31 core.typed-pom-0.3.30 core.typed-pom-0.3.29 core.typed-pom-0.3.28 core.typed-pom-0.3.27 core.typed-pom-0.3.26 core.typed-pom-0.3.25 core.typed-pom-0.3.24 core.typed-pom-0.3.23 core.typed-pom-0.3.22 core.typed-pom-0.3.21 core.typed-pom-0.3.20 core.typed-pom-0.3.19 core.typed-pom-0.3.18 core.typed-pom-0.3.17 core.typed-pom-0.3.16 core.typed-pom-0.3.15 core.typed-pom-0.3.14 core.typed-pom-0.3.13 core.typed-pom-0.3.12 core.typed-pom-0.3.11 core.typed-pom-0.3.10 core.typed-pom-0.3.9 core.typed-pom-0.3.8 core.typed-pom-0.3.7 core.typed-pom-0.3.6 core.typed-pom-0.3.5 core.typed-pom-0.3.4 core.typed-pom-0.3.3 core.typed-pom-0.3.2 core.typed-pom-0.3.1 core.typed-pom-0.3.0 core.typed-pom-0.3.0-alpha5 core.typed-pom-0.3.0-alpha4 core.typed-pom-0.3.0-alpha3 core.typed-pom-0.3.0-alpha2 core.typed-pom-0.3.0-alpha1 core.typed-pom-0.2.92 core.typed-pom-0.2.91 core.typed-pom-0.2.90 core.typed-pom-0.2.89 core.typed-pom-0.2.88 core.typed-pom-0.2.87 core.typed-pom-0.2.86 core.typed-pom-0.2.85 core.typed-pom-0.2.84 core.typed-pom-0.2.83 core.typed-pom-0.2.82 core.typed-pom-0.2.81 core.typed-pom-0.2.80 core.typed-pom-0.2.79 core.typed-pom-0.2.78 core.typed-pom-0.2.77 core.typed-pom-0.2.76 core.typed-pom-0.2.75 core.typed-pom-0.2.74 core.typed-pom-0.2.73 core.typed-pom-0.2.72 core.typed-pom-0.2.71 core.typed-pom-0.2.70 core.typed-pom-0.2.69 core.typed-pom-0.2.68 core.typed-pom-0.2.67 core.typed-pom-0.2.66 core.typed-pom-0.2.65 core.typed-pom-0.2.64 core.typed-pom-0.2.63 core.typed-pom-0.2.62 core.typed-pom-0.2.61 core.typed-pom-0.2.60 core.typed-pom-0.2.59 core.typed-pom-0.2.58 core.typed-pom-0.2.57 core.typed-pom-0.2.56 core.typed-pom-0.2.55 core.typed-pom-0.2.54 core.typed-pom-0.2.53 core.typed-pom-0.2.52 core.typed-pom-0.2.51 core.typed-0.2.50 core.typed-0.2.49 core.typed-0.2.48 core.typed-0.2.47 core.typed-0.2.46 core.typed-0.2.45 core.typed-0.2.44 core.typed-0.2.43 core.typed-0.2.42 core.typed-0.2.41 core.typed-0.2.40 core.typed-0.2.39
Nothing to show
Clone or download
frenchy64 Finish transition to custom expansions
split pre/post passes into separate functions

make scheduled-passes dynamic

experiment

start check2

force analysis when needed

add forward declare

remove bad require

resolve :new, some other updates

remove printing

remove prints

remove print

handle :catch correctly

correctly erase objects in :let + handle :host-field

erase objects going out of scope in letfn

fix infinite loop

repl tests

fix instance? checking

eval t/cast return

maybe-host-form

move instance-call special to host-call special

invalidate analysis cache when rechecking fn methods

remove :unanalyzed cache

fix flow unreachable test

fix hmap test

fix promise test

ensure analysis state is propagated properly

handle special multimethod interop cases

check form FIXME

fix mm tests
Latest commit c73b9ce Aug 1, 2018

README.md

core.typed

Optional typing in Clojure, as a library.

Releases and Dependency Information

Latest stable release is 0.5.3.

Leiningen dependency information:

[org.clojure/core.typed "0.5.3"]

...
; for very recent releases
:repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}

; for slim jars, follow version string with: :classifier "slim"

Maven dependency information:

<dependency>
  <groupId>org.clojure</groupId>
  <artifactId>core.typed</artifactId>
  <version>0.5.3</version>
  <!-- slim jar -->
  <!-- <classifier>slim</classifier> -->
</dependency>

The default jars contain AOT files for faster loading. If jar size is a concern, consider using the slim jar in production.

Compatibility

core.typed supports Clojure 1.9.0 and JDK 1.7+.

Getting started

Tldr; here is a complete project using core.typed.

With the core.typed JAR in your classpath, run the following code to enable automatic type checking. This is how to start with Leiningen.

:injections [(require 'clojure.core.typed)
             (clojure.core.typed/install)]

Next add the following ns metadata to the file you are working with.

(ns test.core
  {:lang :core.typed})

Save the file and run (require 'test.core :reload). This should type check the file automatically.

It's useful to also import clojure.core.typed to annotate expressions.

(ns test.core
  {:lang :core.typed}
  (:require [clojure.core.typed :as t]))

(t/ann f [t/Any :-> t/Int])
(defn f [x]
  (t/cast t/Int x))

Expressions evaluated via eval will also be type checked if the following is true at runtime: (= :core.typed (:lang (meta *ns*))).

Runtime Spec and type inference

core.typed can observe your tests running and generate appropriate annotations for your functions.

First, call (clojure.core.typed/prepare-infer-ns) in the namespace you wish to infer.

Then, run the relevant tests, ensuring you don't accidentally re-load the instrumented namespace.

Finally, call (clojure.core.typed/runtime-infer) to insert core.typed annotations in your file, or (clojure.core.typed/spec-infer) for clojure.spec annotations.

[Talk] Clojure Conj 2012

Video

Mailing List and IRC

Use the core.typed mailing list for core.typed discussion, or try #typed-clojure on Freenode (the main developer is ambrosebs).

Documentation

See wiki.

API Reference

Ambrose's blog

Leiningen Plugin

lein-typed

Vim Plugin

vim-typedclojure

Emacs Mode

typed-clojure-mode

Quickstart

(clojure.core.typed/ann v t) gives var v the static type t.

(clojure.core.typed/ann-form f t) ensures form f is of the static type t.

(clojure.core.typed/check-ns) type checks the current namespace.

(clojure.core.typed/cf t) type checks the form t.

Examples

core.async Rock-paper-scissors

ClojureScript Checker

The ClojureScript checker has not followed the last year of upstream changes, so it does not work. If you would like to help update the checker, please post on the mailing list.

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)

Sponsors

Development is sponsored (via crowdfunding) by

YourKit

YourKit is kindly supporting core.typed and other open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products:

License

Copyright © Ambrose Bonnaire-Sergeant, Rich Hickey & contributors.

Licensed under the EPL (see the file epl.html).

Also contains code copied from the following libraries:

Potemkin

Copyright © 2013 Zachary Tellman

Distributed under the MIT License.

Riddley

Copyright © 2013 Zachary Tellman

Distributed under the MIT License.