Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (20 sloc) 505 Bytes
(ns bank
(:use [fogus.me.trammel :only [provide-contracts anything]]))
(def amount (ref 0))
(defn deposit [a] (dosync (alter amount + a)))
(defn balance [] @amount)
(provide-contracts
[deposit "Defines the contract for a bank deposit"
[a] [number? => anything]]
[balance "Defines the contarct for a balance check"
[ ] [=> number?]])
(comment
(deposit 100)
;=> 100
@amount
;=> 100
(balance)
;=> 100
(deposit :a)
; java.lang.AssertionError: Assert failed: (number? a)
)