 
 (extend clojure.lang.IPersistentMap
   Shrink
-  ;; TODO:
-  ;; this shrink goes into an infinite loop with floats
   {:shrink shrink-map})

(ns simple-check.generators
  (:require [simple-check.util :as util])
  (:import java.util.Random)
  (:refer-clojure :exclude [int vector map]))

(defn random
  ([] (java.util.Random.))

    (let [value (gen rand-seed size)]
      ((k value) rand-seed size))))

;; Combinators
;; ---------------------------------------------------------------------------

(declare choose)

(defn one-of
  [generators]
  (bind (choose 0 (dec (count generators)))
        #(nth generators %)))

(defn elements
  [coll]
  (fmap #(nth coll %)
        (choose 0 (dec (count coll)))))

(defn such-that
  [gen f]
  (fn [rand-seed size]
    (let [value (gen rand-seed size)]
      (if (f value)
        value
        (recur rand-seed size)))))

;; Generators
;; ---------------------------------------------------------------------------

(defn- diff
  [min-range max-range]
  (case [(neg? min-range) (neg? max-range)]
    [true true] (Math/abs (- max-range min-range))
