(bind contract)binds the contract to its var
(defn -minus- ([x y] (- x y)))
(do (bind (contract #'-minus- [])) (bound? #'-minus-)) => true
binds the contract to its var
(defn -minus-
([x y]
(- x y)))
(do (bind (contract #'-minus- []))
(bound? #'-minus-))
=> true(bound? obj)checks if contract is bound to var
(bound? #'-add-) => false
(bound? #'-contract-) => false
(bound? -contract-) => false
checks if contract is bound to var (bound? #'-add-) => false (bound? #'-contract-) => false (bound? -contract-) => false
(contract var inputs)(contract var inputs output)defines a contract given var and arguments
defines a contract given var and arguments
(contract-info {:keys [var] :as contract})returns the contract info
(-> (contract #'-add- [] nil) (contract-info)) => map?
returns the contract info
(-> (contract #'-add- [] nil)
(contract-info))
=> map?(contract-invoke contract & args)invokes the contract
(-> (contract #'-add- [] nil) (contract-invoke 1 2)) => 3
invokes the contract
(-> (contract #'-add- [] nil)
(contract-invoke 1 2))
=> 3(contract-var? var)checks if var contains a contract
(contract-var? #'-add-) => false
(contract-var? #'-contract-) => true
checks if var contains a contract (contract-var? #'-add-) => false (contract-var? #'-contract-) => true
(contract? obj)checks if object is a contract
checks if object is a contract
(defcontract sym & body)defines a contract
(type/defspec <int> integer?)
(defcontract -add- :inputs [<int> <int>])
(-add- 0.5 0.5) => (throws)
defines a contract (type/defspec <int> integer?) (defcontract -add- :inputs [<int> <int>]) (-add- 0.5 0.5) => (throws)
(parse-arg obj)parses an input/output arg
(type/defspec <number> number?)
(parse-arg {<number> :strict})
parses an input/output arg
(type/defspec <number> number?)
(parse-arg {<number> :strict})(unbind obj)unbinds the contract to its var
(do (unbind #'-minus-) (bound? #'-minus-)) => false
unbinds the contract to its var
(do (unbind #'-minus-)
(bound? #'-minus-))
=> falsecljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |