Skip to content
marick edited this page Feb 12, 2013 · 4 revisions

A prediction has three parts: a left-hand side, an arrow, and a right-hand side. With the normal => arrow, the left-hand side and right-hand side are evaluated, then the results are compared using extended equality. Extended equality is by default =, but the type of the right (and sometimes the left) side can change that. By far the two most important cases are:

  • functions

    A function on the right-hand side is given the result of evaluating the left-hand side. If the result is any value that Clojure counts as true, the prediction succeeds.

  • regular expressions

    This prediction:

    (f) => #"foo+"

    ... means the same thing as this:

    (re-find #"foo+" (f)) => truthy

    (truthy is a checker that succeeds when given any value that Clojure counts as true.)


=> is not the only kind of arrow. Other arrows behave differently.

  • =not=> or =deny=>

    The claim checks out only if extended equality does not produce a truthy value.

    (fact (nth-prime 100) =not=> even?)
  • =expands-to=>

    The left-hand side is macroexpanded and compared to the right-hand side:

    (fact (when true 3) =expands-to=> (if true (do 3)))

    Note that neither side is quoted.

  • =future=>

    Acts like a future fact in that it produces a "WORK TO DO" message. This is useful when you've got most of the claims in a fact working, but have to defer finishing one or a few.

Clone this wiki locally