A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://clojure.github.io/core.typed/index.html below:

Gradual Typing 0.3.25 API documentation

Public Variables and Functions
ASeqtype alias
Usage: (ASeq t)
A sequential seq returned from clojure.core/seq
Source

AVectype alias
Usage: (AVec t)
A persistent vector returned from clojure.core/vector (and others)
Source

Agent1type alias
Usage: (Agent1 t)
An agent that can read and write type x.
Source

Agent2type alias
Usage: (Agent2 t t)
An agent that can write type w and read type r.
Source

Alltype alias
Usage: (All binder type)
A polymorphic binder
Source

Anytype alias
Usage: Any
Any is the top type that contains all types.
Source

AnyIntegertype alias
Usage: AnyInteger
A type that returns true for clojure.core/integer?
Source

AnyValuetype alias
Usage: AnyValue
AnyValue contains all Value singleton types
Source

Assoctype alias
Usage: (Assoc type type-pairs*)
A type representing an assoc operation
Source

Atom1type alias
Usage: (Atom1 t)
An atom that can read and write type x.
Source

Atom2type alias
Usage: (Atom2 t)
An atom that can write type w and read type r.
Source

BlockingDereftype alias
Usage: (BlockingDeref t)
A Clojure blocking derefable (see clojure.core/deref).
Source

Booltype alias
Usage: Bool
A boolean
Source

Colltype alias
Usage: (Coll t)
A persistent collection with member type x.
Source

CountRangetype alias
Usage: (CountRange Integer)
       (CountRange Integer Integer)
A type representing a range of counts for a collection
Source

Delaytype alias
Usage: (Delay t)
A Clojure delay (see clojure.core/{delay,force}).
Source

Dereftype alias
Usage: (Deref t)
A Clojure derefable (see clojure.core/deref).
Source

Differencetype alias
Usage: (Difference type type type*)
Difference represents a difference of types.

(Difference t s) is the same as type t with type s removed.

eg. (Difference (U Int Long) Int) => Long
    (Difference (U Num nil) nil)  => Num
Source

Dissoctype alias
Usage: (Dissoc type type*)
A type representing a dissoc operation
Source

EmptyCounttype alias
Usage: EmptyCount
The type of all things with count 0. Use as part of an intersection.
eg. See EmptySeqable.
Source

EmptySeqabletype alias
Usage: (EmptySeqable t)
A type that can be used to create a sequence of member type x
with count 0.
Source

ExInfotype alias
Usage: ExInfo
A Clojure custom exception type.
Source

ExactCounttype alias
Usage: (ExactCount Integer)
A type representing a precise count for a collection
Source

Fntype alias
Usage: Fn
A type that returns true for clojure.core/fn?
Source

Futuretype alias
Usage: (Future t)
A Clojure future (see clojure.core/{future-call,future}).
Source

Gettype alias
Usage: (Get type type)
       (Get type type type)
A type representing a get operation
Source

HMaptype alias
Usage: (HMap :mandatory {Constant Type*} :optional {Constant Type*} :absent-keys #{Constant*} :complete? Boolean)
       (quote {Constant Type*})
HMap is a type for heterogeneous maps.
Source

HSeqtype alias
Usage: (HSeq [fixed*] :filter-sets [FS*] :objects [obj*])
       (HSeq [fixed* rest *] :filter-sets [FS*] :objects [obj*])
       (HSeq [fixed* drest ... bound] :filter-sets [FS*] :objects [obj*])
HSeq is a type for heterogeneous seqs
Source

HSequentialtype alias
Usage: (HSequential [fixed*] :filter-sets [FS*] :objects [obj*])
       (HSequential [fixed* rest *] :filter-sets [FS*] :objects [obj*])
       (HSequential [fixed* drest ... bound] :filter-sets [FS*] :objects [obj*])
HSequential is a type for heterogeneous sequential collections
Source

HSettype alias
Usage: (HSet #{fixed*} :complete? Boolean)
HSet is a type for heterogeneous sets.
Takes a set of simple values. By default
:complete? is true.

eg. (HSet #{:a :b :c} :complete? true)
Source

HVectype alias
Usage: (HVec [fixed*] :filter-sets [FS*] :objects [obj*])
       (HVec [fixed* type *] :filter-sets [FS*] :objects [obj*])
       (HVec [fixed* type ... bound] :filter-sets [FS*] :objects [obj*])
       (quote [fixed*])
       (quote [fixed* type *])
       (quote [fixed* type ... bound])
HVec is a type for heterogeneous vectors.
It extends clojure.core.typed/Vec and is a subtype
of clojure.core.typed/HSequential.
Source

Hierarchytype alias
Usage: Hierarchy
A hierarchy for use with derive, isa? etc.
Source

Itype alias
Usage: (I type*)
I represents an intersection of types
Source

IFntype alias
Usage: (IFn ArityVec+)
       [fixed* -> ret :filters {:then fl, :else fl} :object {:id Foo, :path Bar}]
       [fixed* rest * -> ret :filters {:then fl, :else fl} :object {:id Foo, :path Bar}]
       [fixed* drest ... bound -> ret :filters {:then fl, :else fl} :object {:id Foo, :path Bar}]
An ordered intersection type of function arities.
Source

Idtype alias
Usage: Id
The identity function at the type level.
Source

Inttype alias
Usage: Int
A type that returns true for clojure.core/integer?
Source

Keywordtype alias
Usage: Keyword
A keyword
Source

Kwtype alias
Usage: Kw
A keyword
Source

Listtype alias
Usage: (List t)
A Clojure persistent list.
Source

Maptype alias
Usage: (Map t t)
A persistent map with keys k and vals v.
Source

Multitype alias
Usage: Multi
A Clojure multimethod.
Source

Namespacetype alias
Usage: Namespace
A namespace
Source

Nilabletype alias
Usage: (Nilable t)
A union of x and nil.
Source

NilableNonEmptyASeqtype alias
Usage: (NilableNonEmptyASeq t)
The result of clojure.core/seq.
Source

NilableNonEmptySeqtype alias
Usage: (NilableNonEmptySeq t)
A persistent sequence of member type x with count greater than 0, or nil.
Source

NonEmptyASeqtype alias
Usage: (NonEmptyASeq t)
A sequential non-empty seq retured from clojure.core/seq
Source

NonEmptyAVectype alias
Usage: (NonEmptyAVec t)
A persistent vector returned from clojure.core/vector (and others) and count greater than 0.
Source

NonEmptyColltype alias
Usage: (NonEmptyColl t)
A persistent collection with member type x and count greater than 0.
Source

NonEmptyCounttype alias
Usage: NonEmptyCount
The type of all things with count greater than 0. Use as part of an intersection.
eg. See NonEmptySeq
Source

NonEmptyLazySeqtype alias
Usage: (NonEmptyLazySeq t)
A non-empty lazy sequence of type t
Source

NonEmptySeqtype alias
Usage: (NonEmptySeq t)
A persistent sequence of member type x with count greater than 0.
Source

NonEmptySeqabletype alias
Usage: (NonEmptySeqable t)
A type that can be used to create a sequence of member type x
with count greater than 0.
Source

NonEmptyVectype alias
Usage: (NonEmptyVec t)
A persistent vector with member type x and count greater than 0.
Source

Nothingtype alias
Usage: Nothing
Nothing is the bottom type that inhabits no types
except itself.
Source

Numtype alias
Usage: Num
A type that returns true for clojure.core/number?
Source

Optiontype alias
Usage: (Option t)
A union of x and nil.
Source

Predtype alias
Usage: (Pred type)
A predicate for the given type.

eg. Type for integer?: (Pred Int)
Source

Promisetype alias
Usage: (Promise t)
A Clojure promise (see clojure.core/{promise,deliver}).
Source

Proxytype alias
Usage: Proxy
A Clojure proxy.
Source

Rectype alias
Usage: (Rec binder type)
A recursive type
Source

Ref1type alias
Usage: (Ref1 t)
A ref that can read and write type x.
Source

Ref2type alias
Usage: (Ref2 w r)
A ref that can write type w and read type r.
Source

Reversibletype alias
Usage: (Reversible t)
A Clojure reversible collection.
Source

Seqtype alias
Usage: (Seq t)
A persistent sequence of member type x.
Source

Seqabletype alias
Usage: (Seqable t)
A type that can be used to create a sequence of member type x.
Source

Sequentialtype alias
Usage: Sequential
A sequential collection.
Source

SequentialSeqtype alias
Usage: (SequentialSeq t)
A Clojure sequential sequence. Seq's aren't always Sequential.
Source

SequentialSeqabletype alias
Usage: (SequentialSeqable t)
A sequential, seqable collection. Seq's aren't always Sequential.
Source

Settype alias
Usage: (Set t)
A persistent set with member type x
Source

SortedSettype alias
Usage: (SortedSet t)
A sorted persistent set with member type x
Source

Stacktype alias
Usage: (Stack t)
A Clojure stack.
Source

Strtype alias
Usage: Str
A string
Source

Symtype alias
Usage: Sym
A symbol
Source

Symboltype alias
Usage: Symbol
A symbol
Source

TFntype alias
Usage: (TFn binder type)
A type function
Source

Utype alias
Usage: (U type*)
U represents a union of types
Source

Valtype alias
Usage: (Val Constant)
       (quote Constant)
A singleton type for a constant value.
Source

Valuetype alias
Usage: (Value Constant)
       (quote Constant)
A singleton type for a constant value.
Source

Var1type alias
Usage: (Var1 t)
An var that can read and write type x.
Source

Var2type alias
Usage: (Var2 w r)
An var that can write type w and read type r.
Source

Vectype alias
Usage: (Vec t)
A persistent vector with member type x.
Source

annmacro
Usage: (ann varsym typesyn)
Annotate varsym with type. If unqualified, qualify in the current namespace.
If varsym has metadata {:no-check true}, ignore definitions of varsym 
while type checking.

If annotating vars in namespaces other than the current one, a fully
qualified symbol must be provided. Note that namespace aliases are not
recognised: the *full* namespace must be given in the first part of the symbol.

eg. ; annotate the var foo in this namespace
    (ann foo [Number -> Number])

    ; annotate a var in another namespace
    (ann another.ns/bar [-> nil])
 
    ; don't check this var
    (ann ^:no-check foobar [Integer -> String])
Source

ann-datatypemacro
Usage: (ann-datatype dname [field :- type*] opts*)
       (ann-datatype binder dname [field :- type*] opts*)
Annotate datatype Class name dname with expected fields.
If unqualified, qualify in the current namespace.
Takes an optional type variable binder before the name.

Fields must be specified in the same order as presented 
in deftype, with exactly the same field names.

Also annotates datatype factories and constructors.

Binder is a vector of specs. Each spec is a vector
with the variable name as the first entry, followed by
keyword arguments:
- :variance (mandatory)
  The declared variance of the type variable. Possible
  values are :covariant, :contravariant and :invariant.
- :< (optional)
  The upper type bound of the type variable. Defaults to
  Any, or the most general type of the same rank as the
  lower bound.
- :> (optional)
  The lower type bound of the type variable. Defaults to
  Nothing, or the least general type of the same rank as the
  upper bound.

eg. ; a datatype in the current namespace
    (ann-datatype MyDatatype [a :- Number,
                              b :- Long])

    ; a datatype in another namespace
    (ann-datatype another.ns.TheirDatatype
                  [str :- String,
                   vec :- (Vec Number)])

    ; a datatype, polymorphic in a
    (ann-datatype [[a :variance :covariant]]
                  MyPolyDatatype
                  [str :- String,
                   vec :- (Vec Number)
                   ply :- (Set a)])
Source

ann-formmacro
Usage: (ann-form form ty)
Annotate a form with an expected type.


ann-interfacemacro
Usage: (ann-interface vbnd varsym & methods)
       (ann-interface varsym & methods)
Annotate a possibly polymorphic interface (created with definterface) with method types.

Note: Unlike ann-protocol, omit the target ('this') argument in the method signatures.

eg. (ann-interface IFoo
      bar
      (Fn [-> Any]
          [Number Symbol -> Any])
      baz
      [Number -> Number])
    (definterface IFoo
      (bar [] [n s])
      (baz [n]))

    ; polymorphic protocol
    ; x is scoped in the methods
    (ann-protocol [[x :variance :covariant]]
      IFooPoly
      bar
      (Fn [-> Any]
          [Number Symbol -> Any])
      baz
      [Number -> Number])
    (definterface IFooPoly
      (bar [] [n s])
      (baz [n]))
Source

ann-manymacro
Usage: (ann-many t & vs)
Annotate several vars with type t.

eg. (ann-many FakeSearch
              web1 web2 image1 image2 video1 video2)
Source

ann-precordmacro
Usage: (ann-precord dname vbnd fields & {ancests :unchecked-ancestors, rplc :replace, :as opt})
Annotate record Class name dname with a polymorphic binder and expected fields.
If unqualified, qualify in the current namespace.
Source

ann-protocolmacro
Usage: (ann-protocol vbnd varsym & methods)
       (ann-protocol varsym & methods)
Annotate a possibly polymorphic protocol var with method types.

eg. (ann-protocol IFoo
      bar
      (Fn [IFoo -> Any]
          [IFoo Number Symbol -> Any])
      baz
      [IFoo Number -> Number])
    (defprotocol> IFoo
      (bar [this] [this n s])
      (baz [this n]))

    ; polymorphic protocol
    ; x is scoped in the methods
    (ann-protocol [[x :variance :covariant]]
      IFooPoly
      bar
      (Fn [(IFooPoly x) -> Any]
          [(IFooPoly x) Number Symbol -> Any])
      baz
      [(IFooPoly x) Number -> Number])
    (defprotocol> IFooPoly
      (bar [this] [this n s])
      (baz [this n]))
Source

ann-recordmacro
Usage: (ann-record dname [field :- type*] opts*)
       (ann-record binder dname [field :- type*] opts*)
Annotate record Class name dname with expected fields.
If unqualified, qualify in the current namespace.
Takes an optional type variable binder before the name.

Fields must be specified in the same order as presented 
in defrecord, with exactly the same field names.

Also annotates record factories and constructors.

Binder is a vector of specs. Each spec is a vector
with the variable name as the first entry, followed by
keyword arguments:
- :variance (mandatory)
  The declared variance of the type variable. Possible
  values are :covariant, :contravariant and :invariant.
- :< (optional)
  The upper type bound of the type variable. Defaults to
  Any, or the most general type of the same rank as the
  lower bound.
- :> (optional)
  The lower type bound of the type variable. Defaults to
  Nothing, or the least general type of the same rank as the
  upper bound.

eg. ; a record in the current namespace
    (ann-record MyRecord [a :- Number,
                          b :- Long])

    ; a record in another namespace
    (ann-record another.ns.TheirRecord
                  [str :- String,
                   vec :- (Vec Number)])

    ; a record, polymorphic in a
    (ann-record [[a :variance :covariant]]
                MyPolyRecord
                [str :- String,
                 vec :- (Vec Number)
                 ply :- (Set a)])
Source

atommacro
Usage: (atom & args)
Like atom, but with optional type annotations.

Same as (atom (ann-form init t) args*)

eg. (atom 1) : (Atom1 (Value 1))
    (atom :- Num, 1) : (Atom1 Num)


atom>macro
Usage: (atom> t init & args)
DEPRECATED: use clojure.core.typed/atom

Like atom, but creates an Atom1 of type t.

Same as (atom (ann-form init t) args*)

eg. (atom> Number 1)
    (atom> (Vec Any) [])
Deprecated since Gradual Typing version 0.2.58
Source
castmacro
Usage: (cast t x)
       (cast t x opt)
Cast a value to a type. Returns a new value that conforms
to the given type, otherwise throws an error with blame.

eg. (cast Int 1)
    ;=> 1

    (cast Int nil)
    ; Fail, <blame positive ...>

    ((cast [Int -> Int] identity)
     1)
    ;=> 1

    ((cast [Int -> Int] identity)
     nil)
    ; Fail, <blame negative ...>

    (cast [Int -> Int] nil)
    ; Fail, <blame positive ...>

(defalias Options
  (HMap :optional {:positive (U Sym Str),
                   :negative (U Sym Str)
                   :file (U Str nil)
                   :line (U Int nil)
                   :column (U Int nil)}))

(IFn [Contract Any -> Any]
     [Contract Any Options -> Any]

Options:
- :positive   positive blame, (U Sym Str)
- :negative   negative blame, (U Sym Str)
- :file       file name where contract is checked, (U Str nil)
- :line       line number where contract is checked, (U Int nil)
- :column     column number where contract is checked, (U Int nil)
Source

cfmacro
Usage: (cf form)
       (cf form expected)
Takes a form and an optional expected type and
returns a human-readable inferred type for that form.
Throws an exception if type checking fails.

Do not use cf inside a typed namespace. cf is intended to be
used at the REPL or within a unit test. Note that testing for
truthiness is not sufficient to unit test a call to cf, as nil
and false are valid type syntax.

cf preserves annotations from previous calls to check-ns or cf,
and keeps any new ones collected during a cf. This is useful for
debugging and experimentation. cf may be less strict than check-ns
with type checker warnings.

eg. (cf 1) 
    ;=> Long

    (cf #(inc %) [Number -> Number])
    ;=> [Number -> Number]
Source

check-form*function
Usage: (check-form* form)
       (check-form* form expected)
       (check-form* form expected type-provided?)
Takes a (quoted) form and optional expected type syntax and
type checks the form. If expected is provided, type-provided?
must be true.
Source

check-form-infofunction
Usage: (check-form-info form & opt)
Type checks a (quoted) form and returns a map of results from type checking the
form.

Options
- :expected        Type syntax representing the expected type for this form
                   type-provided? option must be true to utilise the type.
- :type-provided?  If true, use the expected type to check the form.
- :profile         Use Timbre to profile the type checker. Timbre must be
                   added as a dependency. Must use the "slim" JAR.
- :file-mapping    If true, return map provides entry :file-mapping, a hash-map
                   of (Map '{:line Int :column Int :file Str} Str).
- :checked-ast     Returns the entire AST for the given form as the :checked-ast entry,
                   annotated with the static types inferred after checking.
                   If a fatal error occurs, mapped to nil.
- :no-eval         If true, don't evaluate :out-form. Removes :result return value.
                   It is highly recommended to evaluate :out-form manually.

Default return map
- :ret             TCResult inferred for the current form
- :out-form        The macroexpanded result of type-checking, if successful. 
- :result          The evaluated result of :out-form, unless :no-eval is provided.
- :ex              If an exception was thrown during evaluation, this key will be present
                   with the exception as the value.
DEPRECATED
- :delayed-errors  A sequence of delayed errors (ex-info instances)
Source

check-nsfunction
Usage: (check-ns)
       (check-ns ns-or-syms & opt)
Type check a namespace/s (a symbol or Namespace, or collection).
If not provided default to current namespace.
Returns a true value if type checking is successful, otherwise
throws an Exception.

Do not use check-ns within a checked namespace.
It is intended to be used at the REPL or within a unit test.
Suggested idiom for clojure.test: (is (check-ns 'your.ns))

check-ns resets annotations collected from 
previous check-ns calls or cf. A successful check-ns call will
preserve any type annotations collect during that checking run.

Keyword arguments:
- :collect-only  if true, collect type annotations but don't type check code.
                 Useful for debugging purposes.
- :trace         if true, print some basic tracing of the type checker
- :profile       Use Timbre to profile the type checker. Timbre must be
                 added as a dependency. Must use the "slim" JAR.

If providing keyword arguments, the namespace to check must be provided
as the first argument.

Bind clojure.core.typed.util-vars/*verbose-types* to true to print fully qualified types.
Bind clojure.core.typed.util-vars/*verbose-forms* to print full forms in error messages.

eg. (check-ns 'myns.typed)
    ;=> :ok
   
    ; implicitly check current namespace
    (check-ns)
    ;=> :ok

    ; collect but don't check the current namespace
    (check-ns *ns* :collect-only true)
Source

check-ns-infofunction
Usage: (check-ns-info)
       (check-ns-info ns-or-syms & opt)
Same as check-ns, but returns a map of results from type checking the
namespace.

Options
- :collect-only    Don't type check the given namespace/s, but collect the 
                   top level type annotations like ann, ann-record.
- :type-provided?  If true, use the expected type to check the form
- :profile         Use Timbre to profile the type checker. Timbre must be
                   added as a dependency. Must use the "slim" JAR.
- :file-mapping    If true, return map provides entry :file-mapping, a hash-map
                   of (Map '{:line Int :column Int :file Str} Str).

Default return map
- :delayed-errors  A sequence of delayed errors (ex-info instances)
Source

declare-alias-kindmacro
Usage: (declare-alias-kind sym ty)
Declare a kind for an alias, similar to declare but on the kind level.
Source

declare-datatypesmacro
Usage: (declare-datatypes & syms)
Declare datatypes, similar to declare but on the type level.
Source

declare-namesmacro
Usage: (declare-names & syms)
Declare names, similar to declare but on the type level.
Source

declare-protocolsmacro
Usage: (declare-protocols & syms)
Declare protocols, similar to declare but on the type level.
Source

defmacro
Usage: (def name docstring? :- type? expr)
Like clojure.core/def with optional type annotations

NB: in Clojure it is impossible to refer a var called `def` as it is a
special form. Use an alias prefix (eg. `t/def`).

If an annotation is provided, a corresponding `ann` form
is generated, otherwise it expands identically to clojure.core/def

eg. ;same as clojure.core/def
    (def vname 1)
    
    ;with Number `ann`
    (def vname :- Number 1)

    ;doc
    (def vname
      "Docstring"
      :- Long
      1)


def-aliasmacro
Usage: (def-alias sym doc-str t)
       (def-alias sym t)
DEPRECATED: use defalias

Define a type alias. Takes an optional doc-string as a second
argument.

Updates the corresponding var with documentation.

eg. (def-alias MyAlias
      "Here is my alias"
      (U nil String))
Deprecated since Gradual Typing version 0.2.45
Source
def>macro
Usage: (def> name docstring? :- type expr)
DEPRECATED: use clojure.core.typed/def

Like def, but with annotations.

eg. (def> vname :- Long 1)

;doc
(def> vname
  "Docstring"
  :- Long
  1)
Deprecated since Gradual Typing version 0.2.45
Source
defaliasmacro
Usage: (defalias sym doc-str t)
       (defalias sym t)
Define a recursive type alias. Takes an optional doc-string as a second
argument.

Updates the corresponding var with documentation.

eg. (defalias MyAlias
      "Here is my alias"
      (U nil String))

    ;; recursive alias
    (defalias Expr
      (U '{:op ':if :test Expr :then Expr :else Expr}
         '{:op ':const :val Any}))
Source

defnmacro
Usage: (defn kw-args? name docstring? attr-map? [param :- type *] :- type exprs*)
       (defn kw-args? name docstring? attr-map? ([param :- type *] :- type exprs*) +)
Like defn, but expands to clojure.core.typed/fn. If a polymorphic binder is
supplied before the var name, expands to clojure.core.typed/pfn.

eg. (defn fname [a :- Number, b :- (U Symbol nil)] :- Integer ...)

;annotate return
(defn fname [a :- String] :- String ...)

;multi-arity
(defn fname 
  ([a :- String] :- String ...)
  ([a :- String, b :- Number] :- Long ...))

;polymorphic function
(defn :forall [x y]
  fname 
  ([a :- x] :- (Coll y) ...)
  ([a :- Str, b :- y] :- y ...))


defn>macro
Usage: (defn> name docstring? :- type [param :- type *] exprs*)
       (defn> name docstring? (:- type [param :- type *] exprs*) +)
DEPRECATED: Use defn

Like defn, but with annotations. Annotations are mandatory for
parameters and for return type.

eg. (defn> fname :- Integer [a :- Number, b :- (U Symbol nil)] ...)

;annotate return
(defn> fname :- String [a :- String] ...)

;multi-arity
(defn> fname 
  (:- String [a :- String] ...)
  (:- Long   [a :- String, b :- Number] ...))
Deprecated since Gradual Typing version 0.2.57
Source
defprotocolmacro
Usage: (defprotocol & body)
Like defprotocol, but with optional type annotations.

Omitted annotations default to Any. The first argument
of a protocol cannot be annotated.

Add a binder before the protocol name to define a polymorphic
protocol. A binder before the method name defines a polymorphic
method, however a method binder must not shadow type variables
introduced by a protocol binder.

Return types for each method arity can be annotated.

Unlike clojure.core/defprotocol, successive methods can
have the same arity. Semantically, providing multiple successive
methods of the same arity is the same as just providing the left-most
method. However the types for these methods will be accumulated into
a Fn type.

eg. ;annotate single method
(defprotocol MyProtocol
  (a [this a :- Integer] :- Number))

;polymorphic protocol
(defprotocol [[x :variance :covariant]]
  MyProtocol
  (a [this a :- Integer] :- Number))

;multiple types for the same method
(defprotocol [[x :variance :covariant]]
  MyProtocol
  (a [this a :- Integer] :- Integer
     [this a :- Long] :- Long
     [this a :- Number] :- Number))

;polymorphic method+protocol
(defprotocol [[x :variance :covariant]]
  MyProtocol
  ([y] a [this a :- x, b :- y] :- y))


defprotocol>macro
Usage: (defprotocol> & body)
DEPRECATED: use clojure.core.typed/defprotocol

Like defprotocol, but required for type checking
its macroexpansion.

eg. (defprotocol> MyProtocol
      (a [this]))
Deprecated since Gradual Typing version 0.2.45
Source
doseqmacro
Usage: (doseq seq-exprs & body)
Like clojure.core/doseq with optional annotations.

:let option uses clojure.core.typed/let

eg.
(doseq [a :- (U nil AnyInteger) [1 nil 2 3]
        :when a]
   (inc a))
Source

doseq>macro
Usage: (doseq> seq-exprs & body)
DEPRECATED: use clojure.core.typed/doseq

Like doseq but requires annotation for each loop variable: 
[a [1 2]] becomes [a :- Long [1 2]]

eg.
(doseq> [a :- (U nil AnyInteger) [1 nil 2 3]
         :when a]
   (inc a))
Deprecated since Gradual Typing version 0.2.45
Source
dotimesmacro
Usage: (dotimes bindings & body)
Like clojure.core/dotimes, but with optional annotations.

If annotation for binding is omitted, defaults to Int.

eg. (dotimes [_ 100]
      (println "like normal"))

    (dotimes [x :- Num, 100.123]
      (println "like normal" x))
Source

dotimes>macro
Usage: (dotimes> bindings & body)
DEPRECATED: Use clojure.core.typed/dotimes

Like dotimes.

eg. (dotimes> [_ 100]
      (println "like normal"))
Deprecated since Gradual Typing version 0.2.45
Source
envsfunction
Usage: (envs)
Returns a map of type environments, according to the current state of the
type checker.

Output map:
- :vars      map from var symbols to their verbosely printed types
- :aliases   map from alias var symbols (made with defalias) to their verbosely printed types
- :special-types  a set of Vars that are special to the type checker (like Any, U, I)
Source

fnmacro
Usage: (fn name? [param :- type* & param :- type * ?] :- type? exprs*)
       (fn name? ([param :- type* & param :- type * ?] :- type? exprs*) +)
Like clojure.core/fn, but with optional annotations.

eg. ;these forms are equivalent
    (fn [a] b)
    (fn [a :- Any] b)
    (fn [a :- Any] :- Any b)
    (fn [a] :- Any b)

    ;annotate return
    (fn [a :- String] :- String body)

    ;named fn
    (fn fname [a :- String] :- String body)

    ;rest parameter
    (fn [a :- String & b :- Number *] body)

    ;dotted rest parameter
    (fn [a :- String & b :- Number ... x] body)

    ;multi-arity
    (fn fname 
      ([a :- String] :- String ...)
      ([a :- String, b :- Number] :- String ...))

    ; polymorphic binder
    (fn :forall [x y z]
      fname 
      ([a :- String] :- String ...)
      ([a :- String, b :- Number] :- String ...))


fn>macro
Usage: (fn> name? :- type? [param :- type* & param :- type * ?] exprs*)
       (fn> name? (:- type? [param :- type* & param :- type * ?] exprs*) +)
DEPRECATED: use clojure.core.typed/fn

Like fn, but with annotations. Annotations are mandatory
for parameters, with optional annotations for return type.
If fn is named, return type annotation is mandatory.

Suggested idiom: use commas between parameter annotation triples.

eg. (fn> [a :- Number, b :- (U Symbol nil)] ...)

    ;annotate return
    (fn> :- String [a :- String] ...)

    ;named fn
    (fn> fname :- String [a :- String] ...)

    ;multi-arity
    (fn> fname 
      (:- String [a :- String] ...)
      (:- Long   [a :- String, b :- Number] ...))
Deprecated since Gradual Typing version 0.2.45
Source
formacro
Usage: (for seq-exprs & maybe-ann-body-expr)
Like clojure.core/for with optional type annotations.

All types default to Any.

The :let option uses clojure.core.typed/let.

eg. (for [a :- (U nil Int) [1 nil 2 3]
          :when a]
      :- Number
      (inc a))
Source

for>macro
Usage: (for> tk ret-ann seq-exprs body-expr)
DEPRECATED: use clojure.core.typed/for

Like for but requires annotation for each loop variable: [a [1 2]] becomes [a :- Long [1 2]]
Also requires annotation for return type.

eg. (for> :- Number
      [a :- (U nil AnyInteger) [1 nil 2 3]
       :when a]
      (inc a))
Deprecated since Gradual Typing version 0.2.45
Source
instmacro
Usage: (inst inst-of & types)
Instantiate a polymorphic type with a number of types.

eg. (inst foo-fn t1 t2 t3 ...)
Source

inst-ctormacro
Usage: (inst-ctor inst-of & types)
Instantiate a call to a constructor with a number of types.
First argument must be an immediate call to a constructor.
Returns exactly the instantiatee (the first argument).

eg. (inst-ctor (PolyCtor. a b c)
               t1 t2 ...)
Source

installfunction
Usage: (install)
       (install features)
Install the :core.typed :lang. Takes an optional set of features
to install, defaults to `:all`, which is equivalent to the set of
all features.

Features:
  - :load    Installs typed `load` over `clojure.core/load`, which type checks files
             on the presence of a {:lang :core.typed} metadata entry in the `ns` form.
             The metadata must be inserted in the actual `ns` form saved to disk,
             as it is read directly from the file instead of the current Namespace
             metadata.
  - :eval    Installs typed `eval` over `clojure.core/eval`.
             If `(= :core.typed (:lang (meta *ns*)))` is true, the form will be implicitly
             type checked. The syntax save to disk is ignored however.

eg. (install)            ; installs `load` and `eval`
eg. (install :all)       ; installs `load` and `eval`
eg. (install #{:eval})   ; installs `eval`
eg. (install #{:load})   ; installs `load`
Source

into-array>macro
Usage: (into-array> cljt coll)
       (into-array> javat cljt coll)
       (into-array> into-array-syn javat cljt coll)
Make a Java array with Java class javat and Typed Clojure type
cljt. Resulting array will be of type javat, but elements of coll must be under
cljt. cljt should be a subtype of javat (the same or more specific).

*Temporary hack*
into-array-syn is exactly the syntax to put as the first argument to into-array.
Calling resolve on this syntax should give the correct class.
Source

letmacro
Usage: (let [binding :- type? init*] exprs*)
Like clojure.core/let but supports optional type annotations.

eg. (let [a :- Type, b
          a2 1.2]
      body)


letfn>macro
Usage: (letfn> [fn-spec-or-annotation*] expr*)
Like letfn, but each function spec must be annotated.

eg. (letfn> [a :- [Number -> Number]
             (a [b] 2)

             c :- [Symbol -> nil]
             (c [s] nil)]
      ...)
Source

load-if-neededfunction
Usage: (load-if-needed)
Load and initialize all of core.typed if not already
Source

loopmacro
Usage: (loop [binding :- type? init*] exprs*)
Like clojure.core/loop, and supports optional type annotations.
Arguments default to a generalised type based on the initial value.

eg. (loop [a :- Number 1
           b :- (U nil Number) nil]
      ...)


loop>macro
Usage: (loop> [binding :- type init*] exprs*)
DEPRECATED: use clojure.core.typed/loop

Like loop, except loop variables require annotation.

Suggested idiom: use a comma between the type and the initial
expression.

eg. (loop> [a :- Number, 1
            b :- (U nil Number), nil]
      ...)
Deprecated since Gradual Typing version 0.2.45
Source
method-typefunction
Usage: (method-type mname)
Given a method symbol, print the core.typed types assigned to it.
Intended for use at the REPL.
Source

nilable-parammacro
Usage: (nilable-param msym mmap)
Override which parameters in qualified method msym may accept
nilable values. If the parameter is a parameterised type or
an Array, this also declares the parameterised types and the Array type as nilable.

mmap is a map mapping arity parameter number to a set of parameter
positions (integers). If the map contains the key :all then this overrides
other entries. The key can also be :all, which declares all parameters nilable.
Source

non-nil-returnmacro
Usage: (non-nil-return msym arities)
Override the return type of fully qualified method msym to be non-nil.
Takes a set of relevant arities,
represented by the number of parameters it takes (rest parameter counts as one),
or :all which overrides all arities.

eg. ; must use full class name
    (non-nil-return java.lang.Class/getDeclaredMethod :all)
Source

override-constructormacro
Usage: (override-constructor ctorsym typesyn)
Override all constructors for Class ctorsym with type.
Source

override-methodmacro
Usage: (override-method methodsym typesyn)
Override type for qualified method methodsym.

methodsym identifies the method to override and should be a
namespace-qualified symbol in the form <class>/<method-name>.
The class name needs to be fully qualified.

typesyn uses the same annotation syntax as functions.

Use non-nil-return instead of override-method if you want to
declare that a method can never return nil.

Example:

  (override-method java.util.Properties/stringPropertyNames
                   [-> (java.util.Set String)])

This overrides the return type of method stringPropertyNames
of class java.util.Properties to be (java.util.Set String).
Source

pfn>macro
Usage: (pfn> & forms)
Define a polymorphic typed anonymous function.
(pfn> name? [binder+] :- type? [[param :- type]* & [param :- type *]?] exprs*)
(pfn> name? [binder+] (:- type? [[param :- type]* & [param :- type *]?] exprs*)+)
Source

predmacro
Usage: (pred t)
Generate a flat (runtime) predicate for type that returns true if the
argument is a subtype of the type, otherwise false.

The current type variable and dotted type variable scope is cleared before parsing.

eg. ((pred Number) 1)
    ;=> true
Source

print-envfunction
Usage: (print-env debug-str)
During type checking, print the type environment to *out*,
preceeded by literal string debug-str.
Source

print-filtersetfunction
Usage: (print-filterset debug-string frm)
During type checking, print the filter set attached to form, 
preceeded by literal string debug-string.
Returns nil.

eg. (let [s (seq (get-a-seqable))]
      (print-filterset "Here now" s))
Source

refmacro
Usage: (ref & args)
Like ref, but with optional type annotations.

Same as (ref (ann-form init t) args*)

eg. (ref 1) : (Ref1 (Value 1))
    (ref :- Num, 1) : (Ref1 Num)


ref>macro
Usage: (ref> t init & args)
DEPRECATED: use clojure.core.typed/ref

Like ref, but creates a Ref1 of type t.

Same as (ref (ann-form init t) args*)

eg. (ref> Number 1)
    (ref> (Vec Any) [])
Deprecated since Gradual Typing version 0.2.58
Source
reset-cachesfunction
Usage: (reset-caches)
Reset internal type caches.
Source

runtime-inferfunction
Usage: (runtime-infer)
       (runtime-infer ns)
Infer and insert annotations for a given namespace.

To instrument your namespace, use the :runtime-infer
feature in your namespace metadata. Note: core.typed
must be installed via `clojure.core.typed/install`.

eg. (ns my-ns
      {:lang :core.typed
       :core.typed {:features #{:runtime-infer}}}
      (:require [clojure.core.typed :as t]))

After your namespace is instrumented, run your tests
and/or exercise the functions in your namespace.

Then call `runtime-infer` to populate the namespace's
corresponding file with these generated annotations.

eg. (runtime-infer) ; infer for *ns*

    (runtime-infer 'my-ns) ; infer for my-ns
Source

statisticsfunction
Usage: (statistics nsyms)
Takes a collection of namespace symbols and returns a map mapping the namespace
symbols to a map of data
Source

tc-ignoremacro
Usage: (tc-ignore & body)
Ignore forms in body during type checking


typed-depsmacro
Usage: (typed-deps & args)
Declare namespaces which should be checked before the current namespace.
Accepts any number of symbols. Only has effect via check-ns.

eg. (typed-deps clojure.core.typed.holes
                myns.types)
Source

untyped-varmacro
Usage: (untyped-var varsym typesyn)
Check a given var has the specified type at runtime.
Source

var-coveragefunction
Usage: (var-coverage)
       (var-coverage nsyms-or-nsym)
Summarises annotated var coverage statistics to *out*
for namespaces nsyms, a collection of symbols or a symbol/namespace.
Defaults to the current namespace if no argument provided.
Source

var>macro
Usage: (var> sym)
Like var, but resolves at runtime like ns-resolve and is understood by
the type checker. sym must be fully qualified (without aliases).

eg. (var> clojure.core/+)
Source

warn-on-unannotated-varsmacro
Usage: (warn-on-unannotated-vars)
Allow unannotated vars in the current namespace. 

Emits a warning instead of a type error when checking
a def without a corresponding expected type.

Disables automatic inference of `def` expressions.

eg. (warn-on-unannotated-vars)
Source

when-let-failmacro
Usage: (when-let-fail b & body)
Like when-let, but fails if the binding yields a false value.

clojure.core.typed.base-env-common
Utilities for all implementations of the type checker


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4