Trammel

a contracts-programming library for Clojure

Contracts Programming

the relationship between a class and its clients as a formal agreement, expressing each party's rights and obligations

read more

example

(use '[fogus.me.trammel
         :only [provide-contracts]])

(defn sqr [n] (* n n))

(sqr 10)
;=> 100
(sqr 0)
;=> 0

(provide-contracts
  [sqr "Constraints for squaring"
    [x] [number? (not= 0 x) => number? pos?]])

(sqr 10)
;=> 100
(sqr 0)
; java.lang.AssertionError:
; Assert failed: (not= 0 x)

learn more

clojars → source code → tickets → wiki →