-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Enumerative property-based testing
--   
--   LeanCheck is a simple enumerative property-based testing library.
--   
--   Properties are defined as Haskell functions returning a boolean value
--   which should be true for all possible choices of argument values.
--   LeanCheck applies enumerated argument values to these properties in
--   search for a counterexample. Properties can be viewed as parameterized
--   unit tests.
--   
--   LeanCheck works by producing tiers of test values: a possibly infinite
--   list of finite sublists of same-and-increasingly-sized values.
--   
--   LeanCheck has lean core with only 180 lines of Haskell code.
@package leancheck
@version 0.8.0


-- | LeanCheck is a simple enumerative property-based testing library.
--   
--   This is the core module of the library, with the most basic
--   definitions. If you are looking just to use the library, import and
--   see <a>Test.LeanCheck</a>.
--   
--   If you want to understand how the code works, this is the place to
--   start reading.
--   
--   Other important modules:
--   
--   <ul>
--   <li><a>Test.LeanCheck.Basic</a> exports: <a>Test.LeanCheck.Core</a>,
--   additional <a>tiers</a> constructors (<a>cons6</a> ... <a>cons12</a>)
--   and <a>Listable</a> tuple instances.</li>
--   <li><a>Test.LeanCheck.Tiers</a> exports: functions for advanced
--   Listable definitions.</li>
--   <li><a>Test.LeanCheck</a> exports: <a>Test.LeanCheck.Basic</a>, most
--   of <a>Test.LeanCheck.Tiers</a> and <a>deriveListable</a>.</li>
--   </ul>
module Test.LeanCheck.Core

-- | Does a property <b>hold</b> up to a number of test values?
--   
--   <pre>
--   holds 1000 $ \xs -&gt; length (sort xs) == length xs
--   </pre>
holds :: Testable a => Int -> a -> Bool

-- | Does a property <b>fail</b> for a number of test values?
--   
--   <pre>
--   fails 1000 $ \xs -&gt; xs ++ ys == ys ++ xs
--   </pre>
fails :: Testable a => Int -> a -> Bool

-- | There <b>exists</b> an assignment of values that satisfies a property
--   up to a number of test values?
--   
--   <pre>
--   exists 1000 $ \x -&gt; x &gt; 10
--   </pre>
exists :: Testable a => Int -> a -> Bool

-- | Up to a number of tests to a property, returns <a>Just</a> the first
--   counter-example or <a>Nothing</a> if there is none.
--   
--   <pre>
--   &gt; counterExample 100 $ \xs -&gt; [] `union` xs == (xs::[Int])
--   Just ["[0,0]"]
--   </pre>
counterExample :: Testable a => Int -> a -> Maybe [String]

-- | Lists all counter-examples for a number of tests to a property,
--   
--   <pre>
--   &gt; counterExamples 12 $ \xs -&gt; xs == nub (xs :: [Int])
--   [["[0,0]"],["[0,0,0]"],["[0,0,0,0]"],["[0,0,1]"],["[0,1,0]"]]
--   </pre>
counterExamples :: Testable a => Int -> a -> [[String]]

-- | Up to a number of tests to a property, returns <a>Just</a> the first
--   witness or <a>Nothing</a> if there is none.
--   
--   <pre>
--   &gt; witness 1000 (\x -&gt; x &gt; 1 &amp;&amp; x &lt; 77 &amp;&amp; 77 `rem` x == 0)
--   Just ["7"]
--   </pre>
witness :: Testable a => Int -> a -> Maybe [String]

-- | Lists all witnesses up to a number of tests to a property.
--   
--   <pre>
--   &gt; witnesses 1000 (\x -&gt; x &gt; 1 &amp;&amp; x &lt; 77 &amp;&amp; 77 `rem` x == 0)
--   [["7"],["11"]]
--   </pre>
witnesses :: Testable a => Int -> a -> [[String]]

-- | <a>Testable</a> values are functions of <a>Listable</a> arguments that
--   return boolean values.
--   
--   <ul>
--   <li><pre> Bool</pre></li>
--   <li><pre> Listable a =&gt; a -&gt; Bool</pre></li>
--   <li><pre> (Listable a, Listable b) =&gt; a -&gt; b -&gt;
--   Bool</pre></li>
--   <li><pre> (Listable a, Listable b, Listable c) =&gt; a -&gt; b -&gt; c
--   -&gt; Bool</pre></li>
--   <li><pre> (Listable a, Listable b, Listable c, ...) =&gt; a -&gt; b
--   -&gt; c -&gt; ... -&gt; Bool</pre></li>
--   </ul>
--   
--   For example:
--   
--   <ul>
--   <li><pre> Int -&gt; Bool</pre></li>
--   <li><pre> String -&gt; [Int] -&gt; Bool</pre></li>
--   </ul>
class Testable a
resultiers :: Testable a => a -> [[([String], Bool)]]

-- | List all results of a <a>Testable</a> property. Each result is a pair
--   of a list of strings and a boolean. The list of strings is a printable
--   representation of one possible choice of argument values for the
--   property. Each boolean paired with such a list indicates whether the
--   property holds for this choice. The outer list is potentially infinite
--   and lazily evaluated.
--   
--   <pre>
--   &gt; results (&lt;)
--   [ (["0","0"],    False)
--   , (["0","1"],    True)
--   , (["1","0"],    False)
--   , (["0","(-1)"], False)
--   , (["1","1"],    False)
--   , (["(-1)","0"], True)
--   , (["0","2"],    True)
--   , (["1","(-1)"], False)
--   , ...
--   ]
--   </pre>
--   
--   <pre>
--   &gt; take 10 $ results (\xs -&gt; xs == nub (xs :: [Int]))
--   [ (["[]"],      True)
--   , (["[0]"],     True)
--   , (["[0,0]"],   False)
--   , (["[1]"],     True)
--   , (["[0,0,0]"], False)
--   , ...
--   ]
--   </pre>
results :: Testable a => a -> [([String], Bool)]

-- | A type is <a>Listable</a> when there exists a function that is able to
--   list (ideally all of) its values.
--   
--   Ideally, instances should be defined by a <a>tiers</a> function that
--   returns a (potentially infinite) list of finite sub-lists (tiers): the
--   first sub-list contains elements of size 0, the second sub-list
--   contains elements of size 1 and so on. Size here is defined by the
--   implementor of the type-class instance.
--   
--   For algebraic data types, the general form for <a>tiers</a> is
--   
--   <pre>
--   tiers = cons&lt;N&gt; ConstructorA
--        \/ cons&lt;N&gt; ConstructorB
--        \/ ...
--        \/ cons&lt;N&gt; ConstructorZ
--   </pre>
--   
--   where <tt>N</tt> is the number of arguments of each constructor
--   <tt>A...Z</tt>.
--   
--   Here is a datatype with 4 constructors and its listable instance:
--   
--   <pre>
--   data MyType  =  MyConsA
--                |  MyConsB Int
--                |  MyConsC Int Char
--                |  MyConsD String
--   
--   instance Listable MyType where
--     tiers =  cons0 MyConsA
--           \/ cons1 MyConsB
--           \/ cons2 MyConsC
--           \/ cons1 MyConsD
--   </pre>
--   
--   The instance for Hutton's Razor is given by:
--   
--   <pre>
--   data Expr  =  Val Int
--              |  Add Expr Expr
--   
--   instance Listable Expr where
--     tiers  =  cons1 Val
--            \/ cons2 Add
--   </pre>
--   
--   Instances can be alternatively defined by <a>list</a>. In this case,
--   each sub-list in <a>tiers</a> is a singleton list (each succeeding
--   element of <a>list</a> has +1 size).
--   
--   The function <a>deriveListable</a> from <a>Test.LeanCheck.Derive</a>
--   can automatically derive instances of this typeclass.
--   
--   A <a>Listable</a> instance for functions is also available but is not
--   exported by default. Import <a>Test.LeanCheck.Function</a> if you need
--   to test higher-order properties.
class Listable a
tiers :: Listable a => [[a]]
list :: Listable a => [a]

-- | Given a constructor with no arguments, returns <a>tiers</a> of all
--   possible applications of this constructor. Since in this case there is
--   only one possible application (to no arguments), only a single value,
--   of size/weight 0, will be present in the resulting list of tiers.
cons0 :: a -> [[a]]

-- | Given a constructor with one <a>Listable</a> argument, return
--   <a>tiers</a> of applications of this constructor. By default, returned
--   values will have size/weight of 1.
cons1 :: Listable a => (a -> b) -> [[b]]

-- | Given a constructor with two <a>Listable</a> arguments, return
--   <a>tiers</a> of applications of this constructor. By default, returned
--   values will have size/weight of 1.
cons2 :: (Listable a, Listable b) => (a -> b -> c) -> [[c]]

-- | Returns tiers of applications of a 3-argument constructor.
cons3 :: (Listable a, Listable b, Listable c) => (a -> b -> c -> d) -> [[d]]

-- | Returns tiers of applications of a 4-argument constructor.
cons4 :: (Listable a, Listable b, Listable c, Listable d) => (a -> b -> c -> d -> e) -> [[e]]

-- | Returns tiers of applications of a 5-argument constructor.
--   
--   <a>Test.LeanCheck.Basic</a> defines <a>cons6</a> up to <a>cons12</a>.
--   Those are exported by default from <a>Test.LeanCheck</a>, but are
--   hidden from the Haddock documentation.
cons5 :: (Listable a, Listable b, Listable c, Listable d, Listable e) => (a -> b -> c -> d -> e -> f) -> [[f]]

-- | Delays the enumeration of <a>tiers</a>. Conceptually this function
--   adds to the weight of a constructor.
--   
--   <pre>
--   delay [xs, ys, zs, ... ]  =  [[], xs, ys, zs, ...]
--   </pre>
--   
--   <pre>
--   delay [[x,...], [y,...], ...]  =  [[], [x,...], [y,...], ...]
--   </pre>
--   
--   Typically used when defining <a>Listable</a> instances:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ delay (cons&lt;N&gt; &lt;Constructor&gt;)
--            \/ ...
--   </pre>
delay :: [[a]] -> [[a]]

-- | Resets any delays in a list-of <a>tiers</a>. Conceptually this
--   function makes a constructor "weightless", assuring the first tier is
--   non-empty.
--   
--   <pre>
--   reset [[], [], ..., xs, ys, zs, ...]  =  [xs, ys, zs, ...]
--   </pre>
--   
--   <pre>
--   reset [[], xs, ys, zs, ...]  =  [xs, ys, zs, ...]
--   </pre>
--   
--   <pre>
--   reset [[], [], ..., [x], [y], [z], ...]  =  [[x], [y], [z], ...]
--   </pre>
--   
--   Typically used when defining <a>Listable</a> instances:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ reset (cons&lt;N&gt; &lt;Constructor&gt;)
--            \/ ...
--   </pre>
--   
--   Be careful: do not apply <tt>reset</tt> to recursive data structure
--   constructors. In general this will make the list of size 0 infinite,
--   breaking the <a>tiers</a> invariant (each tier must be finite).
reset :: [[a]] -> [[a]]

-- | Tiers of values that follow a property.
--   
--   Typically used in the definition of <a>Listable</a> tiers:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ cons&lt;N&gt; `suchThat` &lt;condition&gt;
--            \/ ...
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   &gt; tiers `suchThat` odd
--   [[], [1], [-1], [], [], [3], [-3], [], [], [5], ...]
--   </pre>
--   
--   <pre>
--   &gt; tiers `suchThat` even
--   [[0], [], [], [2], [-2], [], [], [4], [-4], [], ...]
--   </pre>
--   
--   This function is just a <a>flip</a>ped version of <a>filterT</a>.
suchThat :: [[a]] -> (a -> Bool) -> [[a]]

-- | Append tiers --- sum of two tiers enumerations.
--   
--   <pre>
--   [xs,ys,zs,...] \/ [as,bs,cs,...]  =  [xs++as, ys++bs, zs++cs, ...]
--   </pre>
(\/) :: [[a]] -> [[a]] -> [[a]]
infixr 7 \/

-- | Interleave tiers --- sum of two tiers enumerations. When in doubt, use
--   <a>\/</a> instead.
--   
--   <pre>
--   [xs,ys,zs,...] \/ [as,bs,cs,...]  =  [xs+|as, ys+|bs, zs+|cs, ...]
--   </pre>
(\\//) :: [[a]] -> [[a]] -> [[a]]
infixr 7 \\//

-- | Take a tiered product of lists of tiers.
--   
--   <pre>
--   [t0,t1,t2,...] &gt;&lt; [u0,u1,u2,...]  =
--     [ t0**u0
--     , t0**u1 ++ t1**u0
--     , t0**u2 ++ t1**u1 ++ t2**u0
--     , ...       ...       ...       ...
--     ]
--     where xs ** ys = [(x,y) | x &lt;- xs, y &lt;- ys]
--   </pre>
--   
--   Example:
--   
--   <pre>
--   [[0],[1],[2],...] &gt;&lt; [[0],[1],[2],...]  =
--     [ [(0,0)]
--     , [(1,0),(0,1)]
--     , [(2,0),(1,1),(0,2)]
--     , [(3,0),(2,1),(1,2),(0,3)]
--     , ...
--     ]
--   </pre>
(><) :: [[a]] -> [[b]] -> [[(a, b)]]
infixr 8 ><

-- | Take a tiered product of lists of tiers. <a>productWith</a> can be
--   defined by <a>&gt;&lt;</a>, as:
--   
--   <pre>
--   productWith f xss yss  =  map (uncurry f) $ xss &gt;&lt; yss
--   </pre>
productWith :: (a -> b -> c) -> [[a]] -> [[b]] -> [[c]]

-- | <a>map</a> over tiers
--   
--   <pre>
--   mapT f [[x], [y,z], [w,...], ...]  =  [[f x], [f y, f z], [f w, ...], ...]
--   </pre>
--   
--   <pre>
--   mapT f [xs, ys, zs, ...]  =  [map f xs, map f ys, map f zs]
--   </pre>
mapT :: (a -> b) -> [[a]] -> [[b]]

-- | <a>filter</a> tiers
--   
--   <pre>
--   filterT p [xs, yz, zs, ...]  =  [filter p xs, filter p ys, filter p zs]
--   </pre>
--   
--   <pre>
--   filterT odd tiers  =  [[], [1], [-1], [], [], [3], [-3], [], [], [5], ...]
--   </pre>
filterT :: (a -> Bool) -> [[a]] -> [[a]]

-- | <a>concat</a> tiers of tiers
concatT :: [[[[a]]]] -> [[a]]

-- | <a>concatMap</a> over tiers
concatMapT :: (a -> [[b]]) -> [[a]] -> [[b]]

-- | Takes a list of values <tt>xs</tt> and transform it into tiers on
--   which each tier is occupied by a single element from <tt>xs</tt>.
--   
--   <pre>
--   &gt; toTiers [x, y, z, ...]
--   [ [x], [y], [z], ...]
--   </pre>
--   
--   To convert back to a list, just <a>concat</a>.
toTiers :: [a] -> [[a]]

-- | Boolean implication operator. Useful for defining conditional
--   properties:
--   
--   <pre>
--   prop_something x y = condition x y ==&gt; something x y
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   &gt; prop_addMonotonic x y  =  y &gt; 0 ==&gt; x + y &gt; x
--   &gt; check prop_addMonotonic
--   +++ OK, passed 200 tests.
--   </pre>
(==>) :: Bool -> Bool -> Bool
infixr 0 ==>

-- | Lazily interleaves two lists, switching between elements of the two.
--   Union/sum of the elements in the lists.
--   
--   <pre>
--   [x,y,z,...] +| [a,b,c,...]  =  [x,a,y,b,z,c,...]
--   </pre>
(+|) :: [a] -> [a] -> [a]
infixr 5 +|

-- | Tiers of <a>Integral</a> values. Can be used as a default
--   implementation of <a>list</a> for <a>Integral</a> types.
--   
--   For types with negative values, like <a>Int</a>, the list starts with
--   0 then intercalates between positives and negatives.
--   
--   <pre>
--   listIntegral  =  [0, 1, -1, 2, -2, 3, -3, 4, -4, ...]
--   </pre>
--   
--   For types without negative values, like <a>Word</a>, the list starts
--   with 0 followed by positives of increasing magnitude.
--   
--   <pre>
--   listIntegral  =  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]
--   </pre>
--   
--   This function will not work for types that throw errors when the
--   result of an arithmetic operation is negative such as <a>Natural</a>.
--   For these, use <tt>[0..]</tt> as the <a>list</a> implementation.
listIntegral :: (Ord a, Num a) => [a]

-- | Tiers of <a>Fractional</a> values. This can be used as the
--   implementation of <a>tiers</a> for <a>Fractional</a> types.
--   
--   <pre>
--   tiersFractional :: [[Rational]]  =
--     [ [  0  % 1]
--     , [  1  % 1]
--     , [(-1) % 1]
--     , [  1  % 2,   2  % 1]
--     , [(-1) % 2, (-2) % 1]
--     , [  1  % 3,   3  % 1]
--     , [(-1) % 3, (-3) % 1]
--     , [  1  % 4,   2  % 3,   3  % 2,   4  % 1]
--     , [(-1) % 4, (-2) % 3, (-3) % 2, (-4) % 1]
--     , [  1  % 5,   5  % 1]
--     , [(-1) % 5, (-5) % 1]
--     , [  1  % 6,   2 % 5,    3  % 4,   4  % 3,   5  % 2,   6  % 1]
--     , [(-1) % 6, (-2) % 5, (-3) % 4, (-4) % 3, (-5) % 2, (-6) % 1]
--     , ...
--     ]
--   </pre>
tiersFractional :: Fractional a => [[a]]

-- | Tiers of <a>Floating</a> values. This can be used as the
--   implementation of <a>tiers</a> for <a>Floating</a> types.
--   
--   This function is equivalent to <a>tiersFractional</a> with positive
--   and negative infinities included: 1<i>0 and -1</i>0.
--   
--   <pre>
--   tiersFloating :: [[Float]] =
--     [ [0.0]
--     , [1.0]
--     , [-1.0, Infinity]
--     , [ 0.5,  2.0, -Infinity]
--     , [-0.5, -2.0]
--     , [ 0.33333334,  3.0]
--     , [-0.33333334, -3.0]
--     , [ 0.25,  0.6666667,  1.5,  4.0]
--     , [-0.25, -0.6666667, -1.5, -4.0]
--     , [ 0.2,  5.0]
--     , [-0.2, -5.0]
--     , [ 0.16666667,  0.4,  0.75,  1.3333334,  2.5,  6.0]
--     , [-0.16666667, -0.4, -0.75, -1.3333334, -2.5, -6.0]
--     , ...
--     ]
--   </pre>
--   
--   <tt>NaN</tt> and <tt>-0</tt> are excluded from this enumeration.
tiersFloating :: Fractional a => [[a]]
instance Test.LeanCheck.Core.Testable GHC.Types.Bool
instance (Test.LeanCheck.Core.Testable b, GHC.Show.Show a, Test.LeanCheck.Core.Listable a) => Test.LeanCheck.Core.Testable (a -> b)
instance Test.LeanCheck.Core.Listable ()
instance Test.LeanCheck.Core.Listable GHC.Types.Int
instance Test.LeanCheck.Core.Listable GHC.Integer.Type.Integer
instance Test.LeanCheck.Core.Listable GHC.Types.Char
instance Test.LeanCheck.Core.Listable GHC.Types.Bool
instance Test.LeanCheck.Core.Listable a => Test.LeanCheck.Core.Listable (GHC.Maybe.Maybe a)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b) => Test.LeanCheck.Core.Listable (Data.Either.Either a b)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b) => Test.LeanCheck.Core.Listable (a, b)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c) => Test.LeanCheck.Core.Listable (a, b, c)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c, Test.LeanCheck.Core.Listable d) => Test.LeanCheck.Core.Listable (a, b, c, d)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c, Test.LeanCheck.Core.Listable d, Test.LeanCheck.Core.Listable e) => Test.LeanCheck.Core.Listable (a, b, c, d, e)
instance Test.LeanCheck.Core.Listable a => Test.LeanCheck.Core.Listable [a]
instance Test.LeanCheck.Core.Listable GHC.Types.Float
instance Test.LeanCheck.Core.Listable GHC.Types.Double
instance Test.LeanCheck.Core.Listable GHC.Types.Ordering


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports <a>Test.LeanCheck.Core</a> along with:
--   
--   <ul>
--   <li>support for <a>Listable</a> 6-tuples up to 12-tuples;</li>
--   <li><a>tiers</a> constructors (<tt>consN</tt>) with arities from 6 up
--   to 12;</li>
--   <li>a <a>Listable</a> <a>Ratio</a> instance (consequently
--   <a>Listable</a> <a>Rational</a>);</li>
--   <li>a <a>Listable</a> <a>Word</a> instance;</li>
--   <li>the operators <a>addWeight</a> and <a>ofWeight</a>.</li>
--   </ul>
--   
--   <a>Test.LeanCheck</a> already exports everything from this module. You
--   are probably better off importing it.
--   
--   You should <i>only</i> import <a>Test.LeanCheck.Basic</a> if you
--   <i>only</i> want the above basic functionality.
module Test.LeanCheck.Basic
cons6 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f) => (a -> b -> c -> d -> e -> f -> g) -> [[g]]
cons7 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g) => (a -> b -> c -> d -> e -> f -> g -> h) -> [[h]]
cons8 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h) => (a -> b -> c -> d -> e -> f -> g -> h -> i) -> [[i]]
cons9 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h, Listable i) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> [[j]]
cons10 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h, Listable i, Listable j) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> [[k]]
cons11 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h, Listable i, Listable j, Listable k) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) -> [[l]]
cons12 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h, Listable i, Listable j, Listable k, Listable l) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) -> [[m]]

-- | Resets the weight of a constructor or tiers.
--   
--   <pre>
--   &gt; [ [], [], ..., xs, ys, zs, ... ] `ofWeight` 1
--   [ [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ xs, ys, zs, ... ] `ofWeight` 2
--   [ [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ [], xs, ys, zs, ... ] `ofWeight` 3
--   [ [], [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   Typically used as an infix operator when defining <a>Listable</a>
--   instances:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ cons&lt;N&gt; &lt;Cons&gt;  `ofWeight`  &lt;W&gt;
--            \/ ...
--   </pre>
--   
--   <i>Warning:</i> do not apply <tt> `ofWeight` 0 </tt> to recursive data
--   structure constructors. In general this will make the list of size 0
--   infinite, breaking the tier invariant (each tier must be finite).
--   
--   <tt> `ofWeight` <i>n</i> </tt> is equivalent to <a>reset</a> followed
--   by <tt><i>n</i></tt> applications of <a>delay</a>.
ofWeight :: [[a]] -> Int -> [[a]]

-- | Adds to the weight of a constructor or tiers.
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ cons&lt;N&gt; &lt;Cons&gt;  `addWeight`  &lt;W&gt;
--            \/ ...
--   </pre>
--   
--   Typically used as an infix operator when defining <a>Listable</a>
--   instances:
--   
--   <pre>
--   &gt; [ xs, ys, zs, ... ] `addWeight` 1
--   [ [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ xs, ys, zs, ... ] `addWeight` 2
--   [ [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ [], xs, ys, zs, ... ] `addWeight` 3
--   [ [], [], [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   <tt> `addWeight` <i>n</i> </tt> is equivalent to <tt><i>n</i></tt>
--   applications of <a>delay</a>.
addWeight :: [[a]] -> Int -> [[a]]
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c, Test.LeanCheck.Core.Listable d, Test.LeanCheck.Core.Listable e, Test.LeanCheck.Core.Listable f) => Test.LeanCheck.Core.Listable (a, b, c, d, e, f)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c, Test.LeanCheck.Core.Listable d, Test.LeanCheck.Core.Listable e, Test.LeanCheck.Core.Listable f, Test.LeanCheck.Core.Listable g) => Test.LeanCheck.Core.Listable (a, b, c, d, e, f, g)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c, Test.LeanCheck.Core.Listable d, Test.LeanCheck.Core.Listable e, Test.LeanCheck.Core.Listable f, Test.LeanCheck.Core.Listable g, Test.LeanCheck.Core.Listable h) => Test.LeanCheck.Core.Listable (a, b, c, d, e, f, g, h)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c, Test.LeanCheck.Core.Listable d, Test.LeanCheck.Core.Listable e, Test.LeanCheck.Core.Listable f, Test.LeanCheck.Core.Listable g, Test.LeanCheck.Core.Listable h, Test.LeanCheck.Core.Listable i) => Test.LeanCheck.Core.Listable (a, b, c, d, e, f, g, h, i)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c, Test.LeanCheck.Core.Listable d, Test.LeanCheck.Core.Listable e, Test.LeanCheck.Core.Listable f, Test.LeanCheck.Core.Listable g, Test.LeanCheck.Core.Listable h, Test.LeanCheck.Core.Listable i, Test.LeanCheck.Core.Listable j) => Test.LeanCheck.Core.Listable (a, b, c, d, e, f, g, h, i, j)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c, Test.LeanCheck.Core.Listable d, Test.LeanCheck.Core.Listable e, Test.LeanCheck.Core.Listable f, Test.LeanCheck.Core.Listable g, Test.LeanCheck.Core.Listable h, Test.LeanCheck.Core.Listable i, Test.LeanCheck.Core.Listable j, Test.LeanCheck.Core.Listable k) => Test.LeanCheck.Core.Listable (a, b, c, d, e, f, g, h, i, j, k)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b, Test.LeanCheck.Core.Listable c, Test.LeanCheck.Core.Listable d, Test.LeanCheck.Core.Listable e, Test.LeanCheck.Core.Listable f, Test.LeanCheck.Core.Listable g, Test.LeanCheck.Core.Listable h, Test.LeanCheck.Core.Listable i, Test.LeanCheck.Core.Listable j, Test.LeanCheck.Core.Listable k, Test.LeanCheck.Core.Listable l) => Test.LeanCheck.Core.Listable (a, b, c, d, e, f, g, h, i, j, k, l)
instance (GHC.Real.Integral a, Test.LeanCheck.Core.Listable a) => Test.LeanCheck.Core.Listable (GHC.Real.Ratio a)
instance Test.LeanCheck.Core.Listable GHC.Types.Word


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   Needs GHC and Template Haskell (tested on GHC 7.4, 7.6, 7.8, 7.10,
--   8.0, 8.2 and 8.4).
--   
--   If LeanCheck does not compile under later GHCs, this module is
--   probably the culprit.
--   
--   If you rather do this through GHC Generics, please see:
--   <a>Test.LeanCheck.Generic</a> (experimental).
module Test.LeanCheck.Derive

-- | Derives a <a>Listable</a> instance for a given type <a>Name</a>.
--   
--   Consider the following <tt>Stack</tt> datatype:
--   
--   <pre>
--   data Stack a = Stack a (Stack a) | Empty
--   </pre>
--   
--   Writing
--   
--   <pre>
--   deriveListable ''Stack
--   </pre>
--   
--   will automatically derive the following <a>Listable</a> instance:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Stack a) where
--     tiers = cons2 Stack \/ cons0 Empty
--   </pre>
--   
--   <b>Warning:</b> if the values in your type need to follow a data
--   invariant, the derived instance won't respect it. Use this only on
--   "free" datatypes.
--   
--   Needs the <tt>TemplateHaskell</tt> extension.
deriveListable :: Name -> DecsQ

-- | Same as <a>deriveListable</a> but does not warn when the requested
--   instance already exists. The function <a>deriveListable</a> is
--   preferable in most situations.
deriveListableIfNeeded :: Name -> DecsQ

-- | Derives a <a>Listable</a> instance for a given type <a>Name</a>
--   cascading derivation of type arguments as well.
--   
--   Consider the following series of datatypes:
--   
--   <pre>
--   data Position = CEO | Manager | Programmer
--   
--   data Person = Person
--               { name :: String
--               , age :: Int
--               , position :: Position
--               }
--   
--   data Company = Company
--                { name :: String
--                , employees :: [Person]
--                }
--   </pre>
--   
--   Writing
--   
--   <pre>
--   deriveListableCascading ''Company
--   </pre>
--   
--   will automatically derive the following three <a>Listable</a>
--   instances:
--   
--   <pre>
--   instance Listable Position where
--     tiers = cons0 CEO \/ cons0 Manager \/ cons0 Programmer
--   
--   instance Listable Person where
--     tiers = cons3 Person
--   
--   instance Listable Company where
--     tiers = cons2 Company
--   </pre>
deriveListableCascading :: Name -> DecsQ

-- | Given a type <a>Name</a>, derives an expression to be placed as the
--   result of <a>tiers</a>:
--   
--   <pre>
--   consN C1 \/ consN C2 \/ ... \/ consN CN
--   </pre>
--   
--   This function can be used in the definition of <a>Listable</a>
--   instances:
--   
--   <pre>
--   instance Listable MyType where
--     tiers = $(deriveTiers)
--   </pre>
deriveTiers :: Name -> ExpQ

-- | Given a type <a>Name</a>, derives an expression to be placed as the
--   result of <a>list</a>:
--   
--   <pre>
--   concat $ consN C1 \/ consN C2 \/ ... \/ consN CN
--   </pre>
deriveList :: Name -> ExpQ


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   A toy Eq instance for Functions.
--   
--   Warning: this is only intended to be used in testing modules. Avoid
--   importing this on modules that are used as libraries.
module Test.LeanCheck.Function.Eq
instance (Test.LeanCheck.Core.Listable a, GHC.Classes.Eq b) => GHC.Classes.Eq (a -> b)


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This is an experimental module for deriving <a>Listable</a> instances
--   through GHC's generic.
--   
--   If you rather do this through Template Haskell please see:
--   <a>Test.LeanCheck.Derive</a>.
module Test.LeanCheck.Generic

-- | A generic implementation of <a>list</a> for instances of
--   <a>Generic</a>.
--   
--   Use it to define your <a>Listable</a> instances like so:
--   
--   <pre>
--   instance Listable MyType where
--     list = genericList
--   </pre>
--   
--   Consider using <a>genericTiers</a> instead of this (unless you know
--   what you're doing).
genericList :: (Generic a, Listable' (Rep a)) => [a]

-- | A generic implementation of <a>tiers</a> for instances of
--   <a>Generic</a>.
--   
--   Use it to define your <a>Listable</a> instances like so:
--   
--   <pre>
--   instance Listable MyType where
--     tiers = genericTiers
--   </pre>
genericTiers :: (Generic a, Listable' (Rep a)) => [[a]]
instance Test.LeanCheck.Generic.Listable' GHC.Generics.V1
instance Test.LeanCheck.Generic.Listable' GHC.Generics.U1
instance Test.LeanCheck.Core.Listable c => Test.LeanCheck.Generic.Listable' (GHC.Generics.K1 i c)
instance (Test.LeanCheck.Generic.Listable' a, Test.LeanCheck.Generic.Listable' b) => Test.LeanCheck.Generic.Listable' (a GHC.Generics.:+: b)
instance (Test.LeanCheck.Generic.Listable' a, Test.LeanCheck.Generic.Listable' b) => Test.LeanCheck.Generic.Listable' (a GHC.Generics.:*: b)
instance Test.LeanCheck.Generic.Listable' f => Test.LeanCheck.Generic.Listable' (GHC.Generics.M1 i c f)


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   QuickCheck-like interface to <a>Test.LeanCheck</a>
module Test.LeanCheck.IO

-- | Checks a property printing results on <tt>stdout</tt>
--   
--   <pre>
--   &gt; check $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 200 tests.
--   &gt; check $ \xs ys -&gt; xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   </pre>
check :: Testable a => a -> IO ()

-- | Check a property for a given number of tests printing results on
--   <tt>stdout</tt>
--   
--   <pre>
--   &gt; checkFor 1000 $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 1000 tests.
--   </pre>
checkFor :: Testable a => Int -> a -> IO ()

-- | Check a property printing results on <tt>stdout</tt> and returning
--   <a>True</a> on success.
--   
--   <pre>
--   &gt; p &lt;- checkResult $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 200 tests.
--   &gt; q &lt;- checkResult $ \xs ys -&gt; xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   &gt; p &amp;&amp; q
--   False
--   </pre>
--   
--   There is no option to silence this function: for silence, you should
--   use <a>holds</a>.
checkResult :: Testable a => a -> IO Bool

-- | Check a property for a given number of tests printing results on
--   <tt>stdout</tt> and returning <a>True</a> on success.
--   
--   <pre>
--   &gt; checkResultFor 1000 $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 1000 tests.
--   True
--   </pre>
--   
--   There is no option to silence this function: for silence, you should
--   use <a>holds</a>.
checkResultFor :: Testable a => Int -> a -> IO Bool
instance GHC.Show.Show Test.LeanCheck.IO.Result
instance GHC.Classes.Eq Test.LeanCheck.IO.Result


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports functions to compute statistics of Listable
--   instances.
module Test.LeanCheck.Stats
classStats :: (Listable a, Show b) => Int -> (a -> b) -> IO ()
classStatsT :: (Listable a, Show b) => Int -> (a -> b) -> IO ()
conditionStats :: Listable a => Int -> [(String, a -> Bool)] -> IO ()
conditionStatsT :: Listable a => Int -> [(String, a -> Bool)] -> IO ()
classify :: Eq a => [a] -> [[a]]
classifyBy :: (a -> a -> Bool) -> [a] -> [[a]]
classifyOn :: Eq b => (a -> b) -> [a] -> [[a]]
counts :: Eq a => [a] -> [(a, Int)]
countsBy :: (a -> a -> Bool) -> [a] -> [(a, Int)]
countsOn :: Eq b => (a -> b) -> [a] -> [(b, Int)]


-- | LeanCheck is a simple enumerative property-based testing library.
--   
--   This module provides advanced functions for manipulating <a>tiers</a>.
--   Most definitions given here are exported by <a>Test.LeanCheck</a>,
--   except: <a>listCons</a>, <a>choices</a>, <a>setChoices</a> and
--   <a>bagChoices</a>.
module Test.LeanCheck.Tiers

-- | Given a constructor that takes a list, return tiers of applications of
--   this constructor.
--   
--   This is basically a type-restricted version of <a>cons1</a>. You
--   should use <a>cons1</a> instead: this serves more as an illustration
--   of how <a>setCons</a> and <a>bagCons</a> work (see source).
listCons :: Listable a => ([a] -> b) -> [[b]]

-- | Given a constructor that takes a set of elements (as a list), lists
--   tiers of applications of this constructor.
--   
--   A naive <a>Listable</a> instance for the <a>Set</a> (of
--   <a>Data.Set</a>) would read:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Set a) where
--     tiers = cons0 empty \/ cons2 insert
--   </pre>
--   
--   The above instance has a problem: it generates repeated sets. A more
--   efficient implementation that does not repeat sets is given by:
--   
--   <pre>
--   tiers = setCons fromList
--   </pre>
--   
--   Alternatively, you can use <a>setsOf</a> direclty.
setCons :: Listable a => ([a] -> b) -> [[b]]

-- | Given a constructor that takes a bag of elements (as a list), lists
--   tiers of applications of this constructor.
--   
--   For example, a <tt>Bag</tt> represented as a list.
--   
--   <pre>
--   bagCons Bag
--   </pre>
bagCons :: Listable a => ([a] -> b) -> [[b]]

-- | Given a constructor that takes a map of elements (encoded as a list),
--   lists tiers of applications of this constructor
--   
--   So long as the underlying <a>Listable</a> enumerations have no
--   repetitions, this will generate no repetitions.
--   
--   This allows defining an efficient implementation of <a>tiers</a> that
--   does not repeat maps given by:
--   
--   <pre>
--   tiers = mapCons fromList
--   </pre>
mapCons :: (Listable a, Listable b) => ([(a, b)] -> c) -> [[c]]

-- | Given a constructor that takes a list with no duplicate elements,
--   return tiers of applications of this constructor.
noDupListCons :: Listable a => ([a] -> b) -> [[b]]
maybeCons0 :: Maybe b -> [[b]]
maybeCons1 :: Listable a => (a -> Maybe b) -> [[b]]
maybeCons2 :: (Listable a, Listable b) => (a -> b -> Maybe c) -> [[c]]

-- | Like <a>&gt;&lt;</a>, but over 3 lists of tiers.
product3 :: [[a]] -> [[b]] -> [[c]] -> [[(a, b, c)]]

-- | Like <a>productWith</a>, but over 3 lists of tiers.
product3With :: (a -> b -> c -> d) -> [[a]] -> [[b]] -> [[c]] -> [[d]]

-- | Take the product of lists of tiers by a function returning a
--   <a>Maybe</a> value discarding <a>Nothing</a> values.
productMaybeWith :: (a -> b -> Maybe c) -> [[a]] -> [[b]] -> [[c]]

-- | Takes as argument tiers of element values; returns tiers of lists of
--   elements.
--   
--   <pre>
--   listsOf [[]]  =  [[[]]]
--   </pre>
--   
--   <pre>
--   listsOf [[x]]  =  [ [[]]
--                     , [[x]]
--                     , [[x,x]]
--                     , [[x,x,x]]
--                     , ...
--                     ]
--   </pre>
--   
--   <pre>
--   listsOf [[x],[y]]  =  [ [[]]
--                         , [[x]]
--                         , [[x,x],[y]]
--                         , [[x,x,x],[x,y],[y,x]]
--                         , ...
--                         ]
--   </pre>
listsOf :: [[a]] -> [[[a]]]

-- | Takes as argument tiers of element values; returns tiers of
--   size-ordered lists of elements possibly with repetition.
--   
--   <pre>
--   bagsOf [[0],[1],[2],...] =
--     [ [[]]
--     , [[0]]
--     , [[0,0],[1]]
--     , [[0,0,0],[0,1],[2]]
--     , [[0,0,0,0],[0,0,1],[0,2],[1,1],[3]]
--     , [[0,0,0,0,0],[0,0,0,1],[0,0,2],[0,1,1],[0,3],[1,2],[4]]
--     , ...
--     ]
--   </pre>
bagsOf :: [[a]] -> [[[a]]]

-- | Takes as argument tiers of element values; returns tiers of
--   size-ordered lists of elements without repetition.
--   
--   <pre>
--   setsOf [[0],[1],[2],...] =
--     [ [[]]
--     , [[0]]
--     , [[1]]
--     , [[0,1],[2]]
--     , [[0,2],[3]]
--     , [[0,3],[1,2],[4]]
--     , [[0,1,2],[0,4],[1,3],[5]]
--     , ...
--     ]
--   </pre>
--   
--   Can be used in the constructor of specialized <a>Listable</a>
--   instances. For <a>Set</a> (from <a>Data.Set</a>), we would have:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Set a) where
--     tiers = mapT fromList $ setsOf tiers
--   </pre>
setsOf :: [[a]] -> [[[a]]]

-- | Takes as argument tiers of element values; returns tiers of lists with
--   no repeated elements.
--   
--   <pre>
--   noDupListsOf [[0],[1],[2],...] ==
--     [ [[]]
--     , [[0]]
--     , [[1]]
--     , [[0,1],[1,0],[2]]
--     , [[0,2],[2,0],[3]]
--     , ...
--     ]
--   </pre>
noDupListsOf :: [[a]] -> [[[a]]]

-- | Takes the product of N lists of tiers, producing lists of length N.
--   
--   Alternatively, takes as argument a list of lists of tiers of elements;
--   returns lists combining elements of each list of tiers.
--   
--   <pre>
--   products [xss]  =  mapT (:[]) xss
--   products [xss,yss]  =  mapT (\(x,y) -&gt; [x,y]) (xss &gt;&lt; yss)
--   products [xss,yss,zss]  =  product3With (\x y z -&gt; [x,y,z]) xss yss zss
--   </pre>
products :: [[[a]]] -> [[[a]]]

-- | Takes as arguments tiers of source and target values; returns tiers of
--   maps from the source to the target encoded as lists without
--   repetition.
maps :: [[a]] -> [[b]] -> [[[(a, b)]]]

-- | Takes as argument an integer length and tiers of element values;
--   returns tiers of lists of element values of the given length.
--   
--   <pre>
--   listsOfLength 3 [[0],[1],[2],[3],[4]...] =
--     [ [[0,0,0]]
--     , [[0,0,1],[0,1,0],[1,0,0]]
--     , [[0,0,2],[0,1,1],[0,2,0],[1,0,1],[1,1,0],[2,0,0]]
--     , ...
--     ]
--   </pre>
listsOfLength :: Int -> [[a]] -> [[[a]]]

-- | Takes as argument tiers of element values; returns tiers of pairs with
--   distinct element values.
--   
--   When argument tiers have no repeated elements:
--   
--   <pre>
--   distinctPairs xss  =  xss &gt;&lt; xss  `suchThat` uncurry (/=)
--   </pre>
distinctPairs :: [[a]] -> [[(a, a)]]

-- | <a>distinctPairs</a> by a given function:
--   
--   <pre>
--   distinctPairsWith f = mapT (uncurry f) . distinctPairs
--   </pre>
distinctPairsWith :: (a -> a -> b) -> [[a]] -> [[b]]

-- | Takes as argument tiers of element values; returns tiers of unordered
--   pairs where, in enumeration order, the first element is less than or
--   equal to the second.
--   
--   The name of this function is perhaps a misnomer. But in mathematics,
--   an unordered pair is a pair where you don't care about element order,
--   e.g.: <tt>(1,2) = (2,1)</tt>. This function will enumerate canonical
--   versions of such pairs where the first element is less than the
--   second.
--   
--   The returned element pairs can be seen as bags with two elements.
--   
--   When argument tiers are listed in <a>Ord</a>:
--   
--   <pre>
--   distinctPairs xss  =  xss &gt;&lt; xss  `suchThat` uncurry (&lt;=)
--   </pre>
unorderedPairs :: [[a]] -> [[(a, a)]]

-- | <a>unorderedPairs</a> by a given function:
--   
--   <pre>
--   unorderedPairsWith f = mapT (uncurry f) . unorderedPairs
--   </pre>
unorderedPairsWith :: (a -> a -> b) -> [[a]] -> [[b]]

-- | Takes as argument tiers of element values; returns tiers of unordered
--   pairs where, in enumeration order, the first element is strictly less
--   than the second.
--   
--   The returned element pairs can be seen as sets with two elements.
--   
--   When argument tiers are listed in <a>Ord</a>:
--   
--   <pre>
--   distinctPairs xss  =  xss &gt;&lt; xss  `suchThat` uncurry (&lt;)
--   </pre>
unorderedDistinctPairs :: [[a]] -> [[(a, a)]]

-- | <a>unorderedPairs</a> by a given function:
--   
--   <pre>
--   unorderedDistinctPairsWith f = mapT (uncurry f) . unorderedDistinctPairs
--   </pre>
unorderedDistinctPairsWith :: (a -> a -> b) -> [[a]] -> [[b]]

-- | Delete the first occurence of an element in a tier.
--   
--   For normalized lists-of-tiers without repetitions, the following
--   holds:
--   
--   <pre>
--   deleteT x = normalizeT . (`suchThat` (/= x))
--   </pre>
deleteT :: Eq a => a -> [[a]] -> [[a]]

-- | Normalizes tiers by removing up to 12 empty tiers from the end of a
--   list of tiers.
--   
--   <pre>
--   normalizeT [xs0,xs1,...,xsN,[]]     =  [xs0,xs1,...,xsN]
--   normalizeT [xs0,xs1,...,xsN,[],[]]  =  [xs0,xs1,...,xsN]
--   </pre>
--   
--   The arbitrary limit of 12 tiers is necessary as this function would
--   loop if there is an infinite trail of empty tiers.
normalizeT :: [[a]] -> [[a]]

-- | Concatenate tiers of maybes
catMaybesT :: [[Maybe a]] -> [[a]]

-- | Like <tt>mapMaybe</tt> but for tiers.
mapMaybeT :: (a -> Maybe b) -> [[a]] -> [[b]]

-- | Discard elements _not_ matching a predicate.
--   
--   <pre>
--   discardT odd [[1],[2,3],[4]] = [[],[2],[4]]
--   </pre>
discardT :: (a -> Bool) -> [[a]] -> [[a]]

-- | Discard later elements maching a binary predicate (in relation to an
--   earlier element).
--   
--   <pre>
--   discardLaterT (&gt;) [[0],[1],[-1],[2],[-2],...] = [[0],[],[-1],[],[-2],...]
--   discardLaterT (==) [[0],[0,1],[0,1,2],[0,1,2,3],...] = [[0],[1],[2],[3]]
--   </pre>
--   
--   This function is quite innefficient, use with care. Consuming the n-th
--   element takes <tt>O(n^2)</tt> operations.
discardLaterT :: (a -> a -> Bool) -> [[a]] -> [[a]]

-- | Removes repetitions from tiers.
--   
--   <pre>
--   nubT [[0],[0,1],[0,1,2],[0,1,2,3],...] = [[0],[1],[2],[3],...]
--   nubT [[0],[-1,0,1],[-2,-1,0,1,2],...] = [[0],[-1,1],[-2,2],...]
--   </pre>
--   
--   Consuming the n-th element takes <tt>O(n^2)</tt> operations.
nubT :: Ord a => [[a]] -> [[a]]

-- | Lists tiers of choices. Choices are pairs of values and tiers
--   excluding that value.
--   
--   <pre>
--   choices [[False,True]] == [[(False,[[True]]),(True,[[False]])]]
--   choices [[1],[2],[3]]
--     == [ [(1,[[],[2],[3]])]
--        , [(2,[[1],[],[3]])]
--        , [(3,[[1],[2],[]])] ]
--   </pre>
--   
--   Each choice is sized by the extracted element.
choices :: [[a]] -> [[(a, [[a]])]]

-- | Like <a>choices</a> but lists tiers of strictly ascending choices.
--   Used to construct <a>setsOf</a> values.
--   
--   <pre>
--   setChoices [[False,True]] == [[(False,[[True]]),(True,[[]])]]
--   setChoices [[1],[2],[3]]
--     == [ [(1,[[],[2],[3]])]
--        , [(2,[[],[],[3]])]
--        , [(3,[[],[],[]])]
--        ]
--   </pre>
setChoices :: [[a]] -> [[(a, [[a]])]]

-- | Like <a>choices</a> but lists tiers of non-decreasing (ascending)
--   choices. Used to construct <a>bagsOf</a> values.
--   
--   <pre>
--   bagChoices [[False,True]] =
--     [ [(False,[[False,True]]), (True,[[True]])]
--     ]
--   </pre>
--   
--   <pre>
--   bagChoices [[1],[2],[3],...] =
--     [ [(1,[[1],[2],[3],...])]
--     , [(2,[[ ],[2],[3],...])]
--     , [(3,[[ ],[ ],[3],...])]
--     , ...
--     ]
--   </pre>
bagChoices :: [[a]] -> [[(a, [[a]])]]

-- | Alternative to <a>print</a> for <a>tiers</a> with one element per
--   line. (useful for debugging, see also <a>showTiers</a>).
--   
--   <pre>
--   &gt; printTiers 3 (tiers :: [[Int]])
--   [ [0]
--   , [1]
--   , [-1]
--   , ...
--   ]
--   &gt; printTiers 3 (tiers :: [[Bool]])
--   [ [ False
--     , True
--     ]
--   ]
--   </pre>
--   
--   This function can be useful when debugging your <a>Listable</a>
--   instances.
printTiers :: Show a => Int -> [[a]] -> IO ()

-- | Alternative to <a>show</a> for <a>tiers</a> with one element per line.
--   (useful for debugging, see also <a>printTiers</a>).
--   
--   This function can be useful when debugging your <a>Listable</a>
--   instances.
showTiers :: Show a => Int -> [[a]] -> String

-- | Checks if a list-of-tiers is finite.
--   
--   <ul>
--   <li>*Warning:** this is just an approximation, a list-of-tiers is
--   considered finite if it has less than 13 values. This function may
--   give false negatives.</li>
--   </ul>
finite :: [[a]] -> Bool


-- | LeanCheck is a simple enumerative property-based testing library.
--   
--   A <b>property</b> is a function returning a <a>Bool</a> that should be
--   <a>True</a> for all possible choices of arguments. Properties can be
--   viewed as a parameterized unit tests.
--   
--   To check if a property <a>holds</a> by testing up to a thousand
--   values, we evaluate:
--   
--   <pre>
--   holds 1000 property
--   </pre>
--   
--   <a>True</a> indicates success. <a>False</a> indicates a bug.
--   
--   For example:
--   
--   <pre>
--   holds 1000 $ \xs -&gt; length (sort xs) == length (xs::[Int])
--   </pre>
--   
--   To get the smallest <a>counterExample</a> by testing up to a thousand
--   values, we evaluate:
--   
--   <pre>
--   counterExample 1000 property
--   </pre>
--   
--   Arguments of properties should be instances of the <a>Listable</a>
--   typeclass. <a>Listable</a> instances are provided for the most common
--   Haskell types. New instances are easily defined (see <a>Listable</a>
--   for more info).
module Test.LeanCheck

-- | Does a property <b>hold</b> up to a number of test values?
--   
--   <pre>
--   holds 1000 $ \xs -&gt; length (sort xs) == length xs
--   </pre>
holds :: Testable a => Int -> a -> Bool

-- | Does a property <b>fail</b> for a number of test values?
--   
--   <pre>
--   fails 1000 $ \xs -&gt; xs ++ ys == ys ++ xs
--   </pre>
fails :: Testable a => Int -> a -> Bool

-- | There <b>exists</b> an assignment of values that satisfies a property
--   up to a number of test values?
--   
--   <pre>
--   exists 1000 $ \x -&gt; x &gt; 10
--   </pre>
exists :: Testable a => Int -> a -> Bool

-- | Boolean implication operator. Useful for defining conditional
--   properties:
--   
--   <pre>
--   prop_something x y = condition x y ==&gt; something x y
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   &gt; prop_addMonotonic x y  =  y &gt; 0 ==&gt; x + y &gt; x
--   &gt; check prop_addMonotonic
--   +++ OK, passed 200 tests.
--   </pre>
(==>) :: Bool -> Bool -> Bool
infixr 0 ==>

-- | Up to a number of tests to a property, returns <a>Just</a> the first
--   counter-example or <a>Nothing</a> if there is none.
--   
--   <pre>
--   &gt; counterExample 100 $ \xs -&gt; [] `union` xs == (xs::[Int])
--   Just ["[0,0]"]
--   </pre>
counterExample :: Testable a => Int -> a -> Maybe [String]

-- | Lists all counter-examples for a number of tests to a property,
--   
--   <pre>
--   &gt; counterExamples 12 $ \xs -&gt; xs == nub (xs :: [Int])
--   [["[0,0]"],["[0,0,0]"],["[0,0,0,0]"],["[0,0,1]"],["[0,1,0]"]]
--   </pre>
counterExamples :: Testable a => Int -> a -> [[String]]

-- | Up to a number of tests to a property, returns <a>Just</a> the first
--   witness or <a>Nothing</a> if there is none.
--   
--   <pre>
--   &gt; witness 1000 (\x -&gt; x &gt; 1 &amp;&amp; x &lt; 77 &amp;&amp; 77 `rem` x == 0)
--   Just ["7"]
--   </pre>
witness :: Testable a => Int -> a -> Maybe [String]

-- | Lists all witnesses up to a number of tests to a property.
--   
--   <pre>
--   &gt; witnesses 1000 (\x -&gt; x &gt; 1 &amp;&amp; x &lt; 77 &amp;&amp; 77 `rem` x == 0)
--   [["7"],["11"]]
--   </pre>
witnesses :: Testable a => Int -> a -> [[String]]

-- | Checks a property printing results on <tt>stdout</tt>
--   
--   <pre>
--   &gt; check $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 200 tests.
--   &gt; check $ \xs ys -&gt; xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   </pre>
check :: Testable a => a -> IO ()

-- | Check a property for a given number of tests printing results on
--   <tt>stdout</tt>
--   
--   <pre>
--   &gt; checkFor 1000 $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 1000 tests.
--   </pre>
checkFor :: Testable a => Int -> a -> IO ()

-- | Check a property printing results on <tt>stdout</tt> and returning
--   <a>True</a> on success.
--   
--   <pre>
--   &gt; p &lt;- checkResult $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 200 tests.
--   &gt; q &lt;- checkResult $ \xs ys -&gt; xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   &gt; p &amp;&amp; q
--   False
--   </pre>
--   
--   There is no option to silence this function: for silence, you should
--   use <a>holds</a>.
checkResult :: Testable a => a -> IO Bool

-- | Check a property for a given number of tests printing results on
--   <tt>stdout</tt> and returning <a>True</a> on success.
--   
--   <pre>
--   &gt; checkResultFor 1000 $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 1000 tests.
--   True
--   </pre>
--   
--   There is no option to silence this function: for silence, you should
--   use <a>holds</a>.
checkResultFor :: Testable a => Int -> a -> IO Bool

-- | A type is <a>Listable</a> when there exists a function that is able to
--   list (ideally all of) its values.
--   
--   Ideally, instances should be defined by a <a>tiers</a> function that
--   returns a (potentially infinite) list of finite sub-lists (tiers): the
--   first sub-list contains elements of size 0, the second sub-list
--   contains elements of size 1 and so on. Size here is defined by the
--   implementor of the type-class instance.
--   
--   For algebraic data types, the general form for <a>tiers</a> is
--   
--   <pre>
--   tiers = cons&lt;N&gt; ConstructorA
--        \/ cons&lt;N&gt; ConstructorB
--        \/ ...
--        \/ cons&lt;N&gt; ConstructorZ
--   </pre>
--   
--   where <tt>N</tt> is the number of arguments of each constructor
--   <tt>A...Z</tt>.
--   
--   Here is a datatype with 4 constructors and its listable instance:
--   
--   <pre>
--   data MyType  =  MyConsA
--                |  MyConsB Int
--                |  MyConsC Int Char
--                |  MyConsD String
--   
--   instance Listable MyType where
--     tiers =  cons0 MyConsA
--           \/ cons1 MyConsB
--           \/ cons2 MyConsC
--           \/ cons1 MyConsD
--   </pre>
--   
--   The instance for Hutton's Razor is given by:
--   
--   <pre>
--   data Expr  =  Val Int
--              |  Add Expr Expr
--   
--   instance Listable Expr where
--     tiers  =  cons1 Val
--            \/ cons2 Add
--   </pre>
--   
--   Instances can be alternatively defined by <a>list</a>. In this case,
--   each sub-list in <a>tiers</a> is a singleton list (each succeeding
--   element of <a>list</a> has +1 size).
--   
--   The function <a>deriveListable</a> from <a>Test.LeanCheck.Derive</a>
--   can automatically derive instances of this typeclass.
--   
--   A <a>Listable</a> instance for functions is also available but is not
--   exported by default. Import <a>Test.LeanCheck.Function</a> if you need
--   to test higher-order properties.
class Listable a
tiers :: Listable a => [[a]]
list :: Listable a => [a]

-- | Given a constructor with no arguments, returns <a>tiers</a> of all
--   possible applications of this constructor. Since in this case there is
--   only one possible application (to no arguments), only a single value,
--   of size/weight 0, will be present in the resulting list of tiers.
cons0 :: a -> [[a]]

-- | Given a constructor with one <a>Listable</a> argument, return
--   <a>tiers</a> of applications of this constructor. By default, returned
--   values will have size/weight of 1.
cons1 :: Listable a => (a -> b) -> [[b]]

-- | Given a constructor with two <a>Listable</a> arguments, return
--   <a>tiers</a> of applications of this constructor. By default, returned
--   values will have size/weight of 1.
cons2 :: (Listable a, Listable b) => (a -> b -> c) -> [[c]]

-- | Returns tiers of applications of a 3-argument constructor.
cons3 :: (Listable a, Listable b, Listable c) => (a -> b -> c -> d) -> [[d]]

-- | Returns tiers of applications of a 4-argument constructor.
cons4 :: (Listable a, Listable b, Listable c, Listable d) => (a -> b -> c -> d -> e) -> [[e]]

-- | Returns tiers of applications of a 5-argument constructor.
--   
--   <a>Test.LeanCheck.Basic</a> defines <a>cons6</a> up to <a>cons12</a>.
--   Those are exported by default from <a>Test.LeanCheck</a>, but are
--   hidden from the Haddock documentation.
cons5 :: (Listable a, Listable b, Listable c, Listable d, Listable e) => (a -> b -> c -> d -> e -> f) -> [[f]]

-- | Delays the enumeration of <a>tiers</a>. Conceptually this function
--   adds to the weight of a constructor.
--   
--   <pre>
--   delay [xs, ys, zs, ... ]  =  [[], xs, ys, zs, ...]
--   </pre>
--   
--   <pre>
--   delay [[x,...], [y,...], ...]  =  [[], [x,...], [y,...], ...]
--   </pre>
--   
--   Typically used when defining <a>Listable</a> instances:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ delay (cons&lt;N&gt; &lt;Constructor&gt;)
--            \/ ...
--   </pre>
delay :: [[a]] -> [[a]]

-- | Resets any delays in a list-of <a>tiers</a>. Conceptually this
--   function makes a constructor "weightless", assuring the first tier is
--   non-empty.
--   
--   <pre>
--   reset [[], [], ..., xs, ys, zs, ...]  =  [xs, ys, zs, ...]
--   </pre>
--   
--   <pre>
--   reset [[], xs, ys, zs, ...]  =  [xs, ys, zs, ...]
--   </pre>
--   
--   <pre>
--   reset [[], [], ..., [x], [y], [z], ...]  =  [[x], [y], [z], ...]
--   </pre>
--   
--   Typically used when defining <a>Listable</a> instances:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ reset (cons&lt;N&gt; &lt;Constructor&gt;)
--            \/ ...
--   </pre>
--   
--   Be careful: do not apply <tt>reset</tt> to recursive data structure
--   constructors. In general this will make the list of size 0 infinite,
--   breaking the <a>tiers</a> invariant (each tier must be finite).
reset :: [[a]] -> [[a]]

-- | Resets the weight of a constructor or tiers.
--   
--   <pre>
--   &gt; [ [], [], ..., xs, ys, zs, ... ] `ofWeight` 1
--   [ [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ xs, ys, zs, ... ] `ofWeight` 2
--   [ [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ [], xs, ys, zs, ... ] `ofWeight` 3
--   [ [], [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   Typically used as an infix operator when defining <a>Listable</a>
--   instances:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ cons&lt;N&gt; &lt;Cons&gt;  `ofWeight`  &lt;W&gt;
--            \/ ...
--   </pre>
--   
--   <i>Warning:</i> do not apply <tt> `ofWeight` 0 </tt> to recursive data
--   structure constructors. In general this will make the list of size 0
--   infinite, breaking the tier invariant (each tier must be finite).
--   
--   <tt> `ofWeight` <i>n</i> </tt> is equivalent to <a>reset</a> followed
--   by <tt><i>n</i></tt> applications of <a>delay</a>.
ofWeight :: [[a]] -> Int -> [[a]]

-- | Adds to the weight of a constructor or tiers.
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ cons&lt;N&gt; &lt;Cons&gt;  `addWeight`  &lt;W&gt;
--            \/ ...
--   </pre>
--   
--   Typically used as an infix operator when defining <a>Listable</a>
--   instances:
--   
--   <pre>
--   &gt; [ xs, ys, zs, ... ] `addWeight` 1
--   [ [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ xs, ys, zs, ... ] `addWeight` 2
--   [ [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ [], xs, ys, zs, ... ] `addWeight` 3
--   [ [], [], [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   <tt> `addWeight` <i>n</i> </tt> is equivalent to <tt><i>n</i></tt>
--   applications of <a>delay</a>.
addWeight :: [[a]] -> Int -> [[a]]

-- | Tiers of values that follow a property.
--   
--   Typically used in the definition of <a>Listable</a> tiers:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ cons&lt;N&gt; `suchThat` &lt;condition&gt;
--            \/ ...
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   &gt; tiers `suchThat` odd
--   [[], [1], [-1], [], [], [3], [-3], [], [], [5], ...]
--   </pre>
--   
--   <pre>
--   &gt; tiers `suchThat` even
--   [[0], [], [], [2], [-2], [], [], [4], [-4], [], ...]
--   </pre>
--   
--   This function is just a <a>flip</a>ped version of <a>filterT</a>.
suchThat :: [[a]] -> (a -> Bool) -> [[a]]

-- | Append tiers --- sum of two tiers enumerations.
--   
--   <pre>
--   [xs,ys,zs,...] \/ [as,bs,cs,...]  =  [xs++as, ys++bs, zs++cs, ...]
--   </pre>
(\/) :: [[a]] -> [[a]] -> [[a]]
infixr 7 \/

-- | Interleave tiers --- sum of two tiers enumerations. When in doubt, use
--   <a>\/</a> instead.
--   
--   <pre>
--   [xs,ys,zs,...] \/ [as,bs,cs,...]  =  [xs+|as, ys+|bs, zs+|cs, ...]
--   </pre>
(\\//) :: [[a]] -> [[a]] -> [[a]]
infixr 7 \\//

-- | Take a tiered product of lists of tiers.
--   
--   <pre>
--   [t0,t1,t2,...] &gt;&lt; [u0,u1,u2,...]  =
--     [ t0**u0
--     , t0**u1 ++ t1**u0
--     , t0**u2 ++ t1**u1 ++ t2**u0
--     , ...       ...       ...       ...
--     ]
--     where xs ** ys = [(x,y) | x &lt;- xs, y &lt;- ys]
--   </pre>
--   
--   Example:
--   
--   <pre>
--   [[0],[1],[2],...] &gt;&lt; [[0],[1],[2],...]  =
--     [ [(0,0)]
--     , [(1,0),(0,1)]
--     , [(2,0),(1,1),(0,2)]
--     , [(3,0),(2,1),(1,2),(0,3)]
--     , ...
--     ]
--   </pre>
(><) :: [[a]] -> [[b]] -> [[(a, b)]]
infixr 8 ><

-- | Take a tiered product of lists of tiers. <a>productWith</a> can be
--   defined by <a>&gt;&lt;</a>, as:
--   
--   <pre>
--   productWith f xss yss  =  map (uncurry f) $ xss &gt;&lt; yss
--   </pre>
productWith :: (a -> b -> c) -> [[a]] -> [[b]] -> [[c]]

-- | <a>map</a> over tiers
--   
--   <pre>
--   mapT f [[x], [y,z], [w,...], ...]  =  [[f x], [f y, f z], [f w, ...], ...]
--   </pre>
--   
--   <pre>
--   mapT f [xs, ys, zs, ...]  =  [map f xs, map f ys, map f zs]
--   </pre>
mapT :: (a -> b) -> [[a]] -> [[b]]

-- | <a>filter</a> tiers
--   
--   <pre>
--   filterT p [xs, yz, zs, ...]  =  [filter p xs, filter p ys, filter p zs]
--   </pre>
--   
--   <pre>
--   filterT odd tiers  =  [[], [1], [-1], [], [], [3], [-3], [], [], [5], ...]
--   </pre>
filterT :: (a -> Bool) -> [[a]] -> [[a]]

-- | <a>concat</a> tiers of tiers
concatT :: [[[[a]]]] -> [[a]]

-- | <a>concatMap</a> over tiers
concatMapT :: (a -> [[b]]) -> [[a]] -> [[b]]

-- | Delete the first occurence of an element in a tier.
--   
--   For normalized lists-of-tiers without repetitions, the following
--   holds:
--   
--   <pre>
--   deleteT x = normalizeT . (`suchThat` (/= x))
--   </pre>
deleteT :: Eq a => a -> [[a]] -> [[a]]

-- | Normalizes tiers by removing up to 12 empty tiers from the end of a
--   list of tiers.
--   
--   <pre>
--   normalizeT [xs0,xs1,...,xsN,[]]     =  [xs0,xs1,...,xsN]
--   normalizeT [xs0,xs1,...,xsN,[],[]]  =  [xs0,xs1,...,xsN]
--   </pre>
--   
--   The arbitrary limit of 12 tiers is necessary as this function would
--   loop if there is an infinite trail of empty tiers.
normalizeT :: [[a]] -> [[a]]

-- | Takes a list of values <tt>xs</tt> and transform it into tiers on
--   which each tier is occupied by a single element from <tt>xs</tt>.
--   
--   <pre>
--   &gt; toTiers [x, y, z, ...]
--   [ [x], [y], [z], ...]
--   </pre>
--   
--   To convert back to a list, just <a>concat</a>.
toTiers :: [a] -> [[a]]

-- | Derives a <a>Listable</a> instance for a given type <a>Name</a>.
--   
--   Consider the following <tt>Stack</tt> datatype:
--   
--   <pre>
--   data Stack a = Stack a (Stack a) | Empty
--   </pre>
--   
--   Writing
--   
--   <pre>
--   deriveListable ''Stack
--   </pre>
--   
--   will automatically derive the following <a>Listable</a> instance:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Stack a) where
--     tiers = cons2 Stack \/ cons0 Empty
--   </pre>
--   
--   <b>Warning:</b> if the values in your type need to follow a data
--   invariant, the derived instance won't respect it. Use this only on
--   "free" datatypes.
--   
--   Needs the <tt>TemplateHaskell</tt> extension.
deriveListable :: Name -> DecsQ

-- | Derives a <a>Listable</a> instance for a given type <a>Name</a>
--   cascading derivation of type arguments as well.
--   
--   Consider the following series of datatypes:
--   
--   <pre>
--   data Position = CEO | Manager | Programmer
--   
--   data Person = Person
--               { name :: String
--               , age :: Int
--               , position :: Position
--               }
--   
--   data Company = Company
--                { name :: String
--                , employees :: [Person]
--                }
--   </pre>
--   
--   Writing
--   
--   <pre>
--   deriveListableCascading ''Company
--   </pre>
--   
--   will automatically derive the following three <a>Listable</a>
--   instances:
--   
--   <pre>
--   instance Listable Position where
--     tiers = cons0 CEO \/ cons0 Manager \/ cons0 Programmer
--   
--   instance Listable Person where
--     tiers = cons3 Person
--   
--   instance Listable Company where
--     tiers = cons2 Company
--   </pre>
deriveListableCascading :: Name -> DecsQ

-- | Given a constructor that takes a set of elements (as a list), lists
--   tiers of applications of this constructor.
--   
--   A naive <a>Listable</a> instance for the <a>Set</a> (of
--   <a>Data.Set</a>) would read:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Set a) where
--     tiers = cons0 empty \/ cons2 insert
--   </pre>
--   
--   The above instance has a problem: it generates repeated sets. A more
--   efficient implementation that does not repeat sets is given by:
--   
--   <pre>
--   tiers = setCons fromList
--   </pre>
--   
--   Alternatively, you can use <a>setsOf</a> direclty.
setCons :: Listable a => ([a] -> b) -> [[b]]

-- | Given a constructor that takes a bag of elements (as a list), lists
--   tiers of applications of this constructor.
--   
--   For example, a <tt>Bag</tt> represented as a list.
--   
--   <pre>
--   bagCons Bag
--   </pre>
bagCons :: Listable a => ([a] -> b) -> [[b]]

-- | Given a constructor that takes a list with no duplicate elements,
--   return tiers of applications of this constructor.
noDupListCons :: Listable a => ([a] -> b) -> [[b]]

-- | Given a constructor that takes a map of elements (encoded as a list),
--   lists tiers of applications of this constructor
--   
--   So long as the underlying <a>Listable</a> enumerations have no
--   repetitions, this will generate no repetitions.
--   
--   This allows defining an efficient implementation of <a>tiers</a> that
--   does not repeat maps given by:
--   
--   <pre>
--   tiers = mapCons fromList
--   </pre>
mapCons :: (Listable a, Listable b) => ([(a, b)] -> c) -> [[c]]

-- | Like <a>productWith</a>, but over 3 lists of tiers.
product3With :: (a -> b -> c -> d) -> [[a]] -> [[b]] -> [[c]] -> [[d]]

-- | Take the product of lists of tiers by a function returning a
--   <a>Maybe</a> value discarding <a>Nothing</a> values.
productMaybeWith :: (a -> b -> Maybe c) -> [[a]] -> [[b]] -> [[c]]

-- | Takes as argument tiers of element values; returns tiers of lists of
--   elements.
--   
--   <pre>
--   listsOf [[]]  =  [[[]]]
--   </pre>
--   
--   <pre>
--   listsOf [[x]]  =  [ [[]]
--                     , [[x]]
--                     , [[x,x]]
--                     , [[x,x,x]]
--                     , ...
--                     ]
--   </pre>
--   
--   <pre>
--   listsOf [[x],[y]]  =  [ [[]]
--                         , [[x]]
--                         , [[x,x],[y]]
--                         , [[x,x,x],[x,y],[y,x]]
--                         , ...
--                         ]
--   </pre>
listsOf :: [[a]] -> [[[a]]]

-- | Takes as argument tiers of element values; returns tiers of
--   size-ordered lists of elements without repetition.
--   
--   <pre>
--   setsOf [[0],[1],[2],...] =
--     [ [[]]
--     , [[0]]
--     , [[1]]
--     , [[0,1],[2]]
--     , [[0,2],[3]]
--     , [[0,3],[1,2],[4]]
--     , [[0,1,2],[0,4],[1,3],[5]]
--     , ...
--     ]
--   </pre>
--   
--   Can be used in the constructor of specialized <a>Listable</a>
--   instances. For <a>Set</a> (from <a>Data.Set</a>), we would have:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Set a) where
--     tiers = mapT fromList $ setsOf tiers
--   </pre>
setsOf :: [[a]] -> [[[a]]]

-- | Takes as argument tiers of element values; returns tiers of
--   size-ordered lists of elements possibly with repetition.
--   
--   <pre>
--   bagsOf [[0],[1],[2],...] =
--     [ [[]]
--     , [[0]]
--     , [[0,0],[1]]
--     , [[0,0,0],[0,1],[2]]
--     , [[0,0,0,0],[0,0,1],[0,2],[1,1],[3]]
--     , [[0,0,0,0,0],[0,0,0,1],[0,0,2],[0,1,1],[0,3],[1,2],[4]]
--     , ...
--     ]
--   </pre>
bagsOf :: [[a]] -> [[[a]]]

-- | Takes as argument tiers of element values; returns tiers of lists with
--   no repeated elements.
--   
--   <pre>
--   noDupListsOf [[0],[1],[2],...] ==
--     [ [[]]
--     , [[0]]
--     , [[1]]
--     , [[0,1],[1,0],[2]]
--     , [[0,2],[2,0],[3]]
--     , ...
--     ]
--   </pre>
noDupListsOf :: [[a]] -> [[[a]]]

-- | Takes the product of N lists of tiers, producing lists of length N.
--   
--   Alternatively, takes as argument a list of lists of tiers of elements;
--   returns lists combining elements of each list of tiers.
--   
--   <pre>
--   products [xss]  =  mapT (:[]) xss
--   products [xss,yss]  =  mapT (\(x,y) -&gt; [x,y]) (xss &gt;&lt; yss)
--   products [xss,yss,zss]  =  product3With (\x y z -&gt; [x,y,z]) xss yss zss
--   </pre>
products :: [[[a]]] -> [[[a]]]

-- | Takes as argument an integer length and tiers of element values;
--   returns tiers of lists of element values of the given length.
--   
--   <pre>
--   listsOfLength 3 [[0],[1],[2],[3],[4]...] =
--     [ [[0,0,0]]
--     , [[0,0,1],[0,1,0],[1,0,0]]
--     , [[0,0,2],[0,1,1],[0,2,0],[1,0,1],[1,1,0],[2,0,0]]
--     , ...
--     ]
--   </pre>
listsOfLength :: Int -> [[a]] -> [[[a]]]

-- | Tiers of <a>Floating</a> values. This can be used as the
--   implementation of <a>tiers</a> for <a>Floating</a> types.
--   
--   This function is equivalent to <a>tiersFractional</a> with positive
--   and negative infinities included: 1<i>0 and -1</i>0.
--   
--   <pre>
--   tiersFloating :: [[Float]] =
--     [ [0.0]
--     , [1.0]
--     , [-1.0, Infinity]
--     , [ 0.5,  2.0, -Infinity]
--     , [-0.5, -2.0]
--     , [ 0.33333334,  3.0]
--     , [-0.33333334, -3.0]
--     , [ 0.25,  0.6666667,  1.5,  4.0]
--     , [-0.25, -0.6666667, -1.5, -4.0]
--     , [ 0.2,  5.0]
--     , [-0.2, -5.0]
--     , [ 0.16666667,  0.4,  0.75,  1.3333334,  2.5,  6.0]
--     , [-0.16666667, -0.4, -0.75, -1.3333334, -2.5, -6.0]
--     , ...
--     ]
--   </pre>
--   
--   <tt>NaN</tt> and <tt>-0</tt> are excluded from this enumeration.
tiersFloating :: Fractional a => [[a]]

-- | Tiers of <a>Fractional</a> values. This can be used as the
--   implementation of <a>tiers</a> for <a>Fractional</a> types.
--   
--   <pre>
--   tiersFractional :: [[Rational]]  =
--     [ [  0  % 1]
--     , [  1  % 1]
--     , [(-1) % 1]
--     , [  1  % 2,   2  % 1]
--     , [(-1) % 2, (-2) % 1]
--     , [  1  % 3,   3  % 1]
--     , [(-1) % 3, (-3) % 1]
--     , [  1  % 4,   2  % 3,   3  % 2,   4  % 1]
--     , [(-1) % 4, (-2) % 3, (-3) % 2, (-4) % 1]
--     , [  1  % 5,   5  % 1]
--     , [(-1) % 5, (-5) % 1]
--     , [  1  % 6,   2 % 5,    3  % 4,   4  % 3,   5  % 2,   6  % 1]
--     , [(-1) % 6, (-2) % 5, (-3) % 4, (-4) % 3, (-5) % 2, (-6) % 1]
--     , ...
--     ]
--   </pre>
tiersFractional :: Fractional a => [[a]]

-- | Tiers of <a>Integral</a> values. Can be used as a default
--   implementation of <a>list</a> for <a>Integral</a> types.
--   
--   For types with negative values, like <a>Int</a>, the list starts with
--   0 then intercalates between positives and negatives.
--   
--   <pre>
--   listIntegral  =  [0, 1, -1, 2, -2, 3, -3, 4, -4, ...]
--   </pre>
--   
--   For types without negative values, like <a>Word</a>, the list starts
--   with 0 followed by positives of increasing magnitude.
--   
--   <pre>
--   listIntegral  =  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]
--   </pre>
--   
--   This function will not work for types that throw errors when the
--   result of an arithmetic operation is negative such as <a>Natural</a>.
--   For these, use <tt>[0..]</tt> as the <a>list</a> implementation.
listIntegral :: (Ord a, Num a) => [a]

-- | Lazily interleaves two lists, switching between elements of the two.
--   Union/sum of the elements in the lists.
--   
--   <pre>
--   [x,y,z,...] +| [a,b,c,...]  =  [x,a,y,b,z,c,...]
--   </pre>
(+|) :: [a] -> [a] -> [a]
infixr 5 +|

-- | <a>Testable</a> values are functions of <a>Listable</a> arguments that
--   return boolean values.
--   
--   <ul>
--   <li><pre> Bool</pre></li>
--   <li><pre> Listable a =&gt; a -&gt; Bool</pre></li>
--   <li><pre> (Listable a, Listable b) =&gt; a -&gt; b -&gt;
--   Bool</pre></li>
--   <li><pre> (Listable a, Listable b, Listable c) =&gt; a -&gt; b -&gt; c
--   -&gt; Bool</pre></li>
--   <li><pre> (Listable a, Listable b, Listable c, ...) =&gt; a -&gt; b
--   -&gt; c -&gt; ... -&gt; Bool</pre></li>
--   </ul>
--   
--   For example:
--   
--   <ul>
--   <li><pre> Int -&gt; Bool</pre></li>
--   <li><pre> String -&gt; [Int] -&gt; Bool</pre></li>
--   </ul>
class Testable a

-- | List all results of a <a>Testable</a> property. Each result is a pair
--   of a list of strings and a boolean. The list of strings is a printable
--   representation of one possible choice of argument values for the
--   property. Each boolean paired with such a list indicates whether the
--   property holds for this choice. The outer list is potentially infinite
--   and lazily evaluated.
--   
--   <pre>
--   &gt; results (&lt;)
--   [ (["0","0"],    False)
--   , (["0","1"],    True)
--   , (["1","0"],    False)
--   , (["0","(-1)"], False)
--   , (["1","1"],    False)
--   , (["(-1)","0"], True)
--   , (["0","2"],    True)
--   , (["1","(-1)"], False)
--   , ...
--   ]
--   </pre>
--   
--   <pre>
--   &gt; take 10 $ results (\xs -&gt; xs == nub (xs :: [Int]))
--   [ (["[]"],      True)
--   , (["[0]"],     True)
--   , (["[0,0]"],   False)
--   , (["[1]"],     True)
--   , (["[0,0,0]"], False)
--   , ...
--   ]
--   </pre>
results :: Testable a => a -> [([String], Bool)]


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports means to enumerate functions via lists of pairs.
--   
--   This module considers functions as a finite list of exceptional
--   input-output cases to a default value (list of pairs of arguments and
--   results).
module Test.LeanCheck.Function.ListsOfPairs

-- | Given tiers of argument and result values, return tiers of functional
--   values.
(-->>) :: Eq a => [[a]] -> [[b]] -> [[a -> b]]

-- | Given tiers of input values and tiers of output values, return tiers
--   with all possible lists of input-output pairs. These represent
--   functional relations. In the implementation of <a>--&gt;&gt;</a>, they
--   represent exceptions to a constant function, hence the name
--   <a>exceptionPairs</a>.
exceptionPairs :: [[a]] -> [[b]] -> [[[(a, b)]]]


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports a <a>Listable</a> instance for function
--   enumeration via lists of pairs.
--   
--   This module considers functions as a finite list of exceptional
--   input-output cases to a default value (list of pairs of arguments and
--   results).
module Test.LeanCheck.Function.Listable.ListsOfPairs
instance (GHC.Classes.Eq a, Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b) => Test.LeanCheck.Core.Listable (a -> b)


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports a <tt>Listable</tt> instance for functions.
--   
--   LeanCheck provides one definition of <tt>Listable</tt> functions:
--   
--   <ul>
--   <li><a>Test.LeanCheck.Function.Listable.ListsOfPairs</a>: considers
--   functions as a finite list of exceptional input-output cases to a
--   default value (list of pairs of arguments and results). This is the
--   LeanCheck default, and is the one exported by this module.</li>
--   </ul>
--   
--   In the future, alternative instances could be provided in sub-modules.
--   
--   Warning: this is only intended to be used in testing modules. Avoid
--   importing this on modules that are used as libraries.
module Test.LeanCheck.Function.Listable


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module re-exports <a>Test.LeanCheck</a> but some test functions
--   have been specialized to catch errors (see the explicit export list
--   below).
--   
--   This module is unsafe as it uses <a>unsafePerformIO</a> to catch
--   errors.
module Test.LeanCheck.Error
holds :: Testable a => Int -> a -> Bool
fails :: Testable a => Int -> a -> Bool
exists :: Testable a => Int -> a -> Bool
counterExample :: Testable a => Int -> a -> Maybe [String]
counterExamples :: Testable a => Int -> a -> [[String]]
witness :: Testable a => Int -> a -> Maybe [String]
witnesses :: Testable a => Int -> a -> [[String]]
results :: Testable a => a -> [([String], Bool)]
fromError :: a -> a -> a

-- | Transforms a value into <a>Just</a> that value or <a>Nothing</a> on
--   some errors:
--   
--   <ul>
--   <li>ArithException</li>
--   <li>ArrayException</li>
--   <li>ErrorCall</li>
--   <li>PatternMatchFail</li>
--   </ul>
errorToNothing :: a -> Maybe a
errorToFalse :: Bool -> Bool
errorToTrue :: Bool -> Bool

-- | Transforms a value into <a>Just</a> that value or <a>Nothing</a> on
--   error.
anyErrorToNothing :: a -> Maybe a

-- | <a>Testable</a> values are functions of <a>Listable</a> arguments that
--   return boolean values.
--   
--   <ul>
--   <li><pre> Bool</pre></li>
--   <li><pre> Listable a =&gt; a -&gt; Bool</pre></li>
--   <li><pre> (Listable a, Listable b) =&gt; a -&gt; b -&gt;
--   Bool</pre></li>
--   <li><pre> (Listable a, Listable b, Listable c) =&gt; a -&gt; b -&gt; c
--   -&gt; Bool</pre></li>
--   <li><pre> (Listable a, Listable b, Listable c, ...) =&gt; a -&gt; b
--   -&gt; c -&gt; ... -&gt; Bool</pre></li>
--   </ul>
--   
--   For example:
--   
--   <ul>
--   <li><pre> Int -&gt; Bool</pre></li>
--   <li><pre> String -&gt; [Int] -&gt; Bool</pre></li>
--   </ul>
class Testable a

-- | A type is <a>Listable</a> when there exists a function that is able to
--   list (ideally all of) its values.
--   
--   Ideally, instances should be defined by a <a>tiers</a> function that
--   returns a (potentially infinite) list of finite sub-lists (tiers): the
--   first sub-list contains elements of size 0, the second sub-list
--   contains elements of size 1 and so on. Size here is defined by the
--   implementor of the type-class instance.
--   
--   For algebraic data types, the general form for <a>tiers</a> is
--   
--   <pre>
--   tiers = cons&lt;N&gt; ConstructorA
--        \/ cons&lt;N&gt; ConstructorB
--        \/ ...
--        \/ cons&lt;N&gt; ConstructorZ
--   </pre>
--   
--   where <tt>N</tt> is the number of arguments of each constructor
--   <tt>A...Z</tt>.
--   
--   Here is a datatype with 4 constructors and its listable instance:
--   
--   <pre>
--   data MyType  =  MyConsA
--                |  MyConsB Int
--                |  MyConsC Int Char
--                |  MyConsD String
--   
--   instance Listable MyType where
--     tiers =  cons0 MyConsA
--           \/ cons1 MyConsB
--           \/ cons2 MyConsC
--           \/ cons1 MyConsD
--   </pre>
--   
--   The instance for Hutton's Razor is given by:
--   
--   <pre>
--   data Expr  =  Val Int
--              |  Add Expr Expr
--   
--   instance Listable Expr where
--     tiers  =  cons1 Val
--            \/ cons2 Add
--   </pre>
--   
--   Instances can be alternatively defined by <a>list</a>. In this case,
--   each sub-list in <a>tiers</a> is a singleton list (each succeeding
--   element of <a>list</a> has +1 size).
--   
--   The function <a>deriveListable</a> from <a>Test.LeanCheck.Derive</a>
--   can automatically derive instances of this typeclass.
--   
--   A <a>Listable</a> instance for functions is also available but is not
--   exported by default. Import <a>Test.LeanCheck.Function</a> if you need
--   to test higher-order properties.
class Listable a
tiers :: Listable a => [[a]]
list :: Listable a => [a]

-- | Takes a list of values <tt>xs</tt> and transform it into tiers on
--   which each tier is occupied by a single element from <tt>xs</tt>.
--   
--   <pre>
--   &gt; toTiers [x, y, z, ...]
--   [ [x], [y], [z], ...]
--   </pre>
--   
--   To convert back to a list, just <a>concat</a>.
toTiers :: [a] -> [[a]]

-- | Tiers of <a>Integral</a> values. Can be used as a default
--   implementation of <a>list</a> for <a>Integral</a> types.
--   
--   For types with negative values, like <a>Int</a>, the list starts with
--   0 then intercalates between positives and negatives.
--   
--   <pre>
--   listIntegral  =  [0, 1, -1, 2, -2, 3, -3, 4, -4, ...]
--   </pre>
--   
--   For types without negative values, like <a>Word</a>, the list starts
--   with 0 followed by positives of increasing magnitude.
--   
--   <pre>
--   listIntegral  =  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]
--   </pre>
--   
--   This function will not work for types that throw errors when the
--   result of an arithmetic operation is negative such as <a>Natural</a>.
--   For these, use <tt>[0..]</tt> as the <a>list</a> implementation.
listIntegral :: (Ord a, Num a) => [a]

-- | Tiers of <a>Fractional</a> values. This can be used as the
--   implementation of <a>tiers</a> for <a>Fractional</a> types.
--   
--   <pre>
--   tiersFractional :: [[Rational]]  =
--     [ [  0  % 1]
--     , [  1  % 1]
--     , [(-1) % 1]
--     , [  1  % 2,   2  % 1]
--     , [(-1) % 2, (-2) % 1]
--     , [  1  % 3,   3  % 1]
--     , [(-1) % 3, (-3) % 1]
--     , [  1  % 4,   2  % 3,   3  % 2,   4  % 1]
--     , [(-1) % 4, (-2) % 3, (-3) % 2, (-4) % 1]
--     , [  1  % 5,   5  % 1]
--     , [(-1) % 5, (-5) % 1]
--     , [  1  % 6,   2 % 5,    3  % 4,   4  % 3,   5  % 2,   6  % 1]
--     , [(-1) % 6, (-2) % 5, (-3) % 4, (-4) % 3, (-5) % 2, (-6) % 1]
--     , ...
--     ]
--   </pre>
tiersFractional :: Fractional a => [[a]]

-- | Tiers of <a>Floating</a> values. This can be used as the
--   implementation of <a>tiers</a> for <a>Floating</a> types.
--   
--   This function is equivalent to <a>tiersFractional</a> with positive
--   and negative infinities included: 1<i>0 and -1</i>0.
--   
--   <pre>
--   tiersFloating :: [[Float]] =
--     [ [0.0]
--     , [1.0]
--     , [-1.0, Infinity]
--     , [ 0.5,  2.0, -Infinity]
--     , [-0.5, -2.0]
--     , [ 0.33333334,  3.0]
--     , [-0.33333334, -3.0]
--     , [ 0.25,  0.6666667,  1.5,  4.0]
--     , [-0.25, -0.6666667, -1.5, -4.0]
--     , [ 0.2,  5.0]
--     , [-0.2, -5.0]
--     , [ 0.16666667,  0.4,  0.75,  1.3333334,  2.5,  6.0]
--     , [-0.16666667, -0.4, -0.75, -1.3333334, -2.5, -6.0]
--     , ...
--     ]
--   </pre>
--   
--   <tt>NaN</tt> and <tt>-0</tt> are excluded from this enumeration.
tiersFloating :: Fractional a => [[a]]

-- | <a>map</a> over tiers
--   
--   <pre>
--   mapT f [[x], [y,z], [w,...], ...]  =  [[f x], [f y, f z], [f w, ...], ...]
--   </pre>
--   
--   <pre>
--   mapT f [xs, ys, zs, ...]  =  [map f xs, map f ys, map f zs]
--   </pre>
mapT :: (a -> b) -> [[a]] -> [[b]]

-- | <a>filter</a> tiers
--   
--   <pre>
--   filterT p [xs, yz, zs, ...]  =  [filter p xs, filter p ys, filter p zs]
--   </pre>
--   
--   <pre>
--   filterT odd tiers  =  [[], [1], [-1], [], [], [3], [-3], [], [], [5], ...]
--   </pre>
filterT :: (a -> Bool) -> [[a]] -> [[a]]

-- | <a>concat</a> tiers of tiers
concatT :: [[[[a]]]] -> [[a]]

-- | <a>concatMap</a> over tiers
concatMapT :: (a -> [[b]]) -> [[a]] -> [[b]]

-- | Given a constructor with no arguments, returns <a>tiers</a> of all
--   possible applications of this constructor. Since in this case there is
--   only one possible application (to no arguments), only a single value,
--   of size/weight 0, will be present in the resulting list of tiers.
cons0 :: a -> [[a]]

-- | Given a constructor with one <a>Listable</a> argument, return
--   <a>tiers</a> of applications of this constructor. By default, returned
--   values will have size/weight of 1.
cons1 :: Listable a => (a -> b) -> [[b]]

-- | Given a constructor with two <a>Listable</a> arguments, return
--   <a>tiers</a> of applications of this constructor. By default, returned
--   values will have size/weight of 1.
cons2 :: (Listable a, Listable b) => (a -> b -> c) -> [[c]]

-- | Returns tiers of applications of a 3-argument constructor.
cons3 :: (Listable a, Listable b, Listable c) => (a -> b -> c -> d) -> [[d]]

-- | Returns tiers of applications of a 4-argument constructor.
cons4 :: (Listable a, Listable b, Listable c, Listable d) => (a -> b -> c -> d -> e) -> [[e]]

-- | Returns tiers of applications of a 5-argument constructor.
--   
--   <a>Test.LeanCheck.Basic</a> defines <a>cons6</a> up to <a>cons12</a>.
--   Those are exported by default from <a>Test.LeanCheck</a>, but are
--   hidden from the Haddock documentation.
cons5 :: (Listable a, Listable b, Listable c, Listable d, Listable e) => (a -> b -> c -> d -> e -> f) -> [[f]]

-- | Delays the enumeration of <a>tiers</a>. Conceptually this function
--   adds to the weight of a constructor.
--   
--   <pre>
--   delay [xs, ys, zs, ... ]  =  [[], xs, ys, zs, ...]
--   </pre>
--   
--   <pre>
--   delay [[x,...], [y,...], ...]  =  [[], [x,...], [y,...], ...]
--   </pre>
--   
--   Typically used when defining <a>Listable</a> instances:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ delay (cons&lt;N&gt; &lt;Constructor&gt;)
--            \/ ...
--   </pre>
delay :: [[a]] -> [[a]]

-- | Resets any delays in a list-of <a>tiers</a>. Conceptually this
--   function makes a constructor "weightless", assuring the first tier is
--   non-empty.
--   
--   <pre>
--   reset [[], [], ..., xs, ys, zs, ...]  =  [xs, ys, zs, ...]
--   </pre>
--   
--   <pre>
--   reset [[], xs, ys, zs, ...]  =  [xs, ys, zs, ...]
--   </pre>
--   
--   <pre>
--   reset [[], [], ..., [x], [y], [z], ...]  =  [[x], [y], [z], ...]
--   </pre>
--   
--   Typically used when defining <a>Listable</a> instances:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ reset (cons&lt;N&gt; &lt;Constructor&gt;)
--            \/ ...
--   </pre>
--   
--   Be careful: do not apply <tt>reset</tt> to recursive data structure
--   constructors. In general this will make the list of size 0 infinite,
--   breaking the <a>tiers</a> invariant (each tier must be finite).
reset :: [[a]] -> [[a]]

-- | Tiers of values that follow a property.
--   
--   Typically used in the definition of <a>Listable</a> tiers:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ cons&lt;N&gt; `suchThat` &lt;condition&gt;
--            \/ ...
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   &gt; tiers `suchThat` odd
--   [[], [1], [-1], [], [], [3], [-3], [], [], [5], ...]
--   </pre>
--   
--   <pre>
--   &gt; tiers `suchThat` even
--   [[0], [], [], [2], [-2], [], [], [4], [-4], [], ...]
--   </pre>
--   
--   This function is just a <a>flip</a>ped version of <a>filterT</a>.
suchThat :: [[a]] -> (a -> Bool) -> [[a]]

-- | Lazily interleaves two lists, switching between elements of the two.
--   Union/sum of the elements in the lists.
--   
--   <pre>
--   [x,y,z,...] +| [a,b,c,...]  =  [x,a,y,b,z,c,...]
--   </pre>
(+|) :: [a] -> [a] -> [a]
infixr 5 +|

-- | Append tiers --- sum of two tiers enumerations.
--   
--   <pre>
--   [xs,ys,zs,...] \/ [as,bs,cs,...]  =  [xs++as, ys++bs, zs++cs, ...]
--   </pre>
(\/) :: [[a]] -> [[a]] -> [[a]]
infixr 7 \/

-- | Interleave tiers --- sum of two tiers enumerations. When in doubt, use
--   <a>\/</a> instead.
--   
--   <pre>
--   [xs,ys,zs,...] \/ [as,bs,cs,...]  =  [xs+|as, ys+|bs, zs+|cs, ...]
--   </pre>
(\\//) :: [[a]] -> [[a]] -> [[a]]
infixr 7 \\//

-- | Take a tiered product of lists of tiers.
--   
--   <pre>
--   [t0,t1,t2,...] &gt;&lt; [u0,u1,u2,...]  =
--     [ t0**u0
--     , t0**u1 ++ t1**u0
--     , t0**u2 ++ t1**u1 ++ t2**u0
--     , ...       ...       ...       ...
--     ]
--     where xs ** ys = [(x,y) | x &lt;- xs, y &lt;- ys]
--   </pre>
--   
--   Example:
--   
--   <pre>
--   [[0],[1],[2],...] &gt;&lt; [[0],[1],[2],...]  =
--     [ [(0,0)]
--     , [(1,0),(0,1)]
--     , [(2,0),(1,1),(0,2)]
--     , [(3,0),(2,1),(1,2),(0,3)]
--     , ...
--     ]
--   </pre>
(><) :: [[a]] -> [[b]] -> [[(a, b)]]
infixr 8 ><

-- | Take a tiered product of lists of tiers. <a>productWith</a> can be
--   defined by <a>&gt;&lt;</a>, as:
--   
--   <pre>
--   productWith f xss yss  =  map (uncurry f) $ xss &gt;&lt; yss
--   </pre>
productWith :: (a -> b -> c) -> [[a]] -> [[b]] -> [[c]]

-- | Boolean implication operator. Useful for defining conditional
--   properties:
--   
--   <pre>
--   prop_something x y = condition x y ==&gt; something x y
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   &gt; prop_addMonotonic x y  =  y &gt; 0 ==&gt; x + y &gt; x
--   &gt; check prop_addMonotonic
--   +++ OK, passed 200 tests.
--   </pre>
(==>) :: Bool -> Bool -> Bool
infixr 0 ==>
cons6 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f) => (a -> b -> c -> d -> e -> f -> g) -> [[g]]
cons7 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g) => (a -> b -> c -> d -> e -> f -> g -> h) -> [[h]]
cons8 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h) => (a -> b -> c -> d -> e -> f -> g -> h -> i) -> [[i]]
cons9 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h, Listable i) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> [[j]]
cons10 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h, Listable i, Listable j) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> [[k]]
cons11 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h, Listable i, Listable j, Listable k) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) -> [[l]]
cons12 :: (Listable a, Listable b, Listable c, Listable d, Listable e, Listable f, Listable g, Listable h, Listable i, Listable j, Listable k, Listable l) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) -> [[m]]

-- | Resets the weight of a constructor or tiers.
--   
--   <pre>
--   &gt; [ [], [], ..., xs, ys, zs, ... ] `ofWeight` 1
--   [ [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ xs, ys, zs, ... ] `ofWeight` 2
--   [ [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ [], xs, ys, zs, ... ] `ofWeight` 3
--   [ [], [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   Typically used as an infix operator when defining <a>Listable</a>
--   instances:
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ cons&lt;N&gt; &lt;Cons&gt;  `ofWeight`  &lt;W&gt;
--            \/ ...
--   </pre>
--   
--   <i>Warning:</i> do not apply <tt> `ofWeight` 0 </tt> to recursive data
--   structure constructors. In general this will make the list of size 0
--   infinite, breaking the tier invariant (each tier must be finite).
--   
--   <tt> `ofWeight` <i>n</i> </tt> is equivalent to <a>reset</a> followed
--   by <tt><i>n</i></tt> applications of <a>delay</a>.
ofWeight :: [[a]] -> Int -> [[a]]

-- | Adds to the weight of a constructor or tiers.
--   
--   <pre>
--   instance Listable &lt;Type&gt; where
--     tiers  =  ...
--            \/ cons&lt;N&gt; &lt;Cons&gt;  `addWeight`  &lt;W&gt;
--            \/ ...
--   </pre>
--   
--   Typically used as an infix operator when defining <a>Listable</a>
--   instances:
--   
--   <pre>
--   &gt; [ xs, ys, zs, ... ] `addWeight` 1
--   [ [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ xs, ys, zs, ... ] `addWeight` 2
--   [ [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   <pre>
--   &gt; [ [], xs, ys, zs, ... ] `addWeight` 3
--   [ [], [], [], [], xs, ys, zs, ... ]
--   </pre>
--   
--   <tt> `addWeight` <i>n</i> </tt> is equivalent to <tt><i>n</i></tt>
--   applications of <a>delay</a>.
addWeight :: [[a]] -> Int -> [[a]]

-- | Derives a <a>Listable</a> instance for a given type <a>Name</a>.
--   
--   Consider the following <tt>Stack</tt> datatype:
--   
--   <pre>
--   data Stack a = Stack a (Stack a) | Empty
--   </pre>
--   
--   Writing
--   
--   <pre>
--   deriveListable ''Stack
--   </pre>
--   
--   will automatically derive the following <a>Listable</a> instance:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Stack a) where
--     tiers = cons2 Stack \/ cons0 Empty
--   </pre>
--   
--   <b>Warning:</b> if the values in your type need to follow a data
--   invariant, the derived instance won't respect it. Use this only on
--   "free" datatypes.
--   
--   Needs the <tt>TemplateHaskell</tt> extension.
deriveListable :: Name -> DecsQ

-- | Derives a <a>Listable</a> instance for a given type <a>Name</a>
--   cascading derivation of type arguments as well.
--   
--   Consider the following series of datatypes:
--   
--   <pre>
--   data Position = CEO | Manager | Programmer
--   
--   data Person = Person
--               { name :: String
--               , age :: Int
--               , position :: Position
--               }
--   
--   data Company = Company
--                { name :: String
--                , employees :: [Person]
--                }
--   </pre>
--   
--   Writing
--   
--   <pre>
--   deriveListableCascading ''Company
--   </pre>
--   
--   will automatically derive the following three <a>Listable</a>
--   instances:
--   
--   <pre>
--   instance Listable Position where
--     tiers = cons0 CEO \/ cons0 Manager \/ cons0 Programmer
--   
--   instance Listable Person where
--     tiers = cons3 Person
--   
--   instance Listable Company where
--     tiers = cons2 Company
--   </pre>
deriveListableCascading :: Name -> DecsQ

-- | Checks a property printing results on <tt>stdout</tt>
--   
--   <pre>
--   &gt; check $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 200 tests.
--   &gt; check $ \xs ys -&gt; xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   </pre>
check :: Testable a => a -> IO ()

-- | Check a property for a given number of tests printing results on
--   <tt>stdout</tt>
--   
--   <pre>
--   &gt; checkFor 1000 $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 1000 tests.
--   </pre>
checkFor :: Testable a => Int -> a -> IO ()

-- | Check a property printing results on <tt>stdout</tt> and returning
--   <a>True</a> on success.
--   
--   <pre>
--   &gt; p &lt;- checkResult $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 200 tests.
--   &gt; q &lt;- checkResult $ \xs ys -&gt; xs `union` ys == ys `union` (xs::[Int])
--   *** Failed! Falsifiable (after 4 tests):
--   [] [0,0]
--   &gt; p &amp;&amp; q
--   False
--   </pre>
--   
--   There is no option to silence this function: for silence, you should
--   use <a>holds</a>.
checkResult :: Testable a => a -> IO Bool

-- | Check a property for a given number of tests printing results on
--   <tt>stdout</tt> and returning <a>True</a> on success.
--   
--   <pre>
--   &gt; checkResultFor 1000 $ \xs -&gt; sort (sort xs) == sort (xs::[Int])
--   +++ OK, passed 1000 tests.
--   True
--   </pre>
--   
--   There is no option to silence this function: for silence, you should
--   use <a>holds</a>.
checkResultFor :: Testable a => Int -> a -> IO Bool

-- | Given a constructor that takes a bag of elements (as a list), lists
--   tiers of applications of this constructor.
--   
--   For example, a <tt>Bag</tt> represented as a list.
--   
--   <pre>
--   bagCons Bag
--   </pre>
bagCons :: Listable a => ([a] -> b) -> [[b]]

-- | Given a constructor that takes a set of elements (as a list), lists
--   tiers of applications of this constructor.
--   
--   A naive <a>Listable</a> instance for the <a>Set</a> (of
--   <a>Data.Set</a>) would read:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Set a) where
--     tiers = cons0 empty \/ cons2 insert
--   </pre>
--   
--   The above instance has a problem: it generates repeated sets. A more
--   efficient implementation that does not repeat sets is given by:
--   
--   <pre>
--   tiers = setCons fromList
--   </pre>
--   
--   Alternatively, you can use <a>setsOf</a> direclty.
setCons :: Listable a => ([a] -> b) -> [[b]]

-- | Given a constructor that takes a map of elements (encoded as a list),
--   lists tiers of applications of this constructor
--   
--   So long as the underlying <a>Listable</a> enumerations have no
--   repetitions, this will generate no repetitions.
--   
--   This allows defining an efficient implementation of <a>tiers</a> that
--   does not repeat maps given by:
--   
--   <pre>
--   tiers = mapCons fromList
--   </pre>
mapCons :: (Listable a, Listable b) => ([(a, b)] -> c) -> [[c]]

-- | Given a constructor that takes a list with no duplicate elements,
--   return tiers of applications of this constructor.
noDupListCons :: Listable a => ([a] -> b) -> [[b]]

-- | Like <a>productWith</a>, but over 3 lists of tiers.
product3With :: (a -> b -> c -> d) -> [[a]] -> [[b]] -> [[c]] -> [[d]]

-- | Take the product of lists of tiers by a function returning a
--   <a>Maybe</a> value discarding <a>Nothing</a> values.
productMaybeWith :: (a -> b -> Maybe c) -> [[a]] -> [[b]] -> [[c]]

-- | Takes as argument tiers of element values; returns tiers of lists of
--   elements.
--   
--   <pre>
--   listsOf [[]]  =  [[[]]]
--   </pre>
--   
--   <pre>
--   listsOf [[x]]  =  [ [[]]
--                     , [[x]]
--                     , [[x,x]]
--                     , [[x,x,x]]
--                     , ...
--                     ]
--   </pre>
--   
--   <pre>
--   listsOf [[x],[y]]  =  [ [[]]
--                         , [[x]]
--                         , [[x,x],[y]]
--                         , [[x,x,x],[x,y],[y,x]]
--                         , ...
--                         ]
--   </pre>
listsOf :: [[a]] -> [[[a]]]

-- | Takes the product of N lists of tiers, producing lists of length N.
--   
--   Alternatively, takes as argument a list of lists of tiers of elements;
--   returns lists combining elements of each list of tiers.
--   
--   <pre>
--   products [xss]  =  mapT (:[]) xss
--   products [xss,yss]  =  mapT (\(x,y) -&gt; [x,y]) (xss &gt;&lt; yss)
--   products [xss,yss,zss]  =  product3With (\x y z -&gt; [x,y,z]) xss yss zss
--   </pre>
products :: [[[a]]] -> [[[a]]]

-- | Delete the first occurence of an element in a tier.
--   
--   For normalized lists-of-tiers without repetitions, the following
--   holds:
--   
--   <pre>
--   deleteT x = normalizeT . (`suchThat` (/= x))
--   </pre>
deleteT :: Eq a => a -> [[a]] -> [[a]]

-- | Normalizes tiers by removing up to 12 empty tiers from the end of a
--   list of tiers.
--   
--   <pre>
--   normalizeT [xs0,xs1,...,xsN,[]]     =  [xs0,xs1,...,xsN]
--   normalizeT [xs0,xs1,...,xsN,[],[]]  =  [xs0,xs1,...,xsN]
--   </pre>
--   
--   The arbitrary limit of 12 tiers is necessary as this function would
--   loop if there is an infinite trail of empty tiers.
normalizeT :: [[a]] -> [[a]]

-- | Takes as argument tiers of element values; returns tiers of lists with
--   no repeated elements.
--   
--   <pre>
--   noDupListsOf [[0],[1],[2],...] ==
--     [ [[]]
--     , [[0]]
--     , [[1]]
--     , [[0,1],[1,0],[2]]
--     , [[0,2],[2,0],[3]]
--     , ...
--     ]
--   </pre>
noDupListsOf :: [[a]] -> [[[a]]]

-- | Takes as argument tiers of element values; returns tiers of
--   size-ordered lists of elements possibly with repetition.
--   
--   <pre>
--   bagsOf [[0],[1],[2],...] =
--     [ [[]]
--     , [[0]]
--     , [[0,0],[1]]
--     , [[0,0,0],[0,1],[2]]
--     , [[0,0,0,0],[0,0,1],[0,2],[1,1],[3]]
--     , [[0,0,0,0,0],[0,0,0,1],[0,0,2],[0,1,1],[0,3],[1,2],[4]]
--     , ...
--     ]
--   </pre>
bagsOf :: [[a]] -> [[[a]]]

-- | Takes as argument tiers of element values; returns tiers of
--   size-ordered lists of elements without repetition.
--   
--   <pre>
--   setsOf [[0],[1],[2],...] =
--     [ [[]]
--     , [[0]]
--     , [[1]]
--     , [[0,1],[2]]
--     , [[0,2],[3]]
--     , [[0,3],[1,2],[4]]
--     , [[0,1,2],[0,4],[1,3],[5]]
--     , ...
--     ]
--   </pre>
--   
--   Can be used in the constructor of specialized <a>Listable</a>
--   instances. For <a>Set</a> (from <a>Data.Set</a>), we would have:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Set a) where
--     tiers = mapT fromList $ setsOf tiers
--   </pre>
setsOf :: [[a]] -> [[[a]]]

-- | Takes as argument an integer length and tiers of element values;
--   returns tiers of lists of element values of the given length.
--   
--   <pre>
--   listsOfLength 3 [[0],[1],[2],[3],[4]...] =
--     [ [[0,0,0]]
--     , [[0,0,1],[0,1,0],[1,0,0]]
--     , [[0,0,2],[0,1,1],[0,2,0],[1,0,1],[1,1,0],[2,0,0]]
--     , ...
--     ]
--   </pre>
listsOfLength :: Int -> [[a]] -> [[[a]]]


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   Some operators for property-based testing.
module Test.LeanCheck.Utils.Operators
(===) :: Eq b => (a -> b) -> (a -> b) -> a -> Bool
infix 4 ===
(====) :: Eq c => (a -> b -> c) -> (a -> b -> c) -> a -> b -> Bool
infix 4 ====
(&&&) :: (a -> Bool) -> (a -> Bool) -> a -> Bool
infixr 3 &&&
(&&&&) :: (a -> b -> Bool) -> (a -> b -> Bool) -> a -> b -> Bool
infixr 3 &&&&
(|||) :: (a -> Bool) -> (a -> Bool) -> a -> Bool
infixr 2 |||
(||||) :: (a -> b -> Bool) -> (a -> b -> Bool) -> a -> b -> Bool
infixr 2 ||||

-- | Is the given function idempotent? <tt>f (f x) == x</tt>
--   
--   <pre>
--   holds n $ idempotent abs
--   holds n $ idempotent sort
--   </pre>
--   
--   <pre>
--   fails n $ idempotent negate
--   </pre>
idempotent :: Eq a => (a -> a) -> a -> Bool

-- | Is the given function an identity? <tt>f x == x</tt>
--   
--   <pre>
--   holds n $ identity (+0)
--   holds n $ identity (sort :: [()])
--   holds n $ identity (not . not)
--   </pre>
identity :: Eq a => (a -> a) -> a -> Bool

-- | Is the given function never an identity? <tt>f x /= x</tt>
--   
--   <pre>
--   holds n $ neverIdentity not
--   </pre>
--   
--   <pre>
--   fails n $ neverIdentity negate   -- yes, fails: negate 0 == 0, hah!
--   </pre>
--   
--   Note: this is not the same as not being an identity.
neverIdentity :: Eq a => (a -> a) -> a -> Bool

-- | Is a given operator commutative? <tt>x + y = y + x</tt>
--   
--   <pre>
--   holds n $ commutative (+)
--   </pre>
--   
--   <pre>
--   fails n $ commutative union  -- union [] [0,0] = [0]
--   </pre>
commutative :: Eq b => (a -> a -> b) -> a -> a -> Bool

-- | Is a given operator associative? <tt>x + (y + z) = (x + y) + z</tt>
associative :: Eq a => (a -> a -> a) -> a -> a -> a -> Bool

-- | Does the first operator, distributes over the second?
distributive :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool

-- | Are two operators flipped versions of each other?
--   
--   <pre>
--   holds n $ (&lt;)  `symmetric2` (&gt;)  -:&gt; int
--   holds n $ (&lt;=) `symmetric2` (&gt;=) -:&gt; int
--   </pre>
--   
--   <pre>
--   fails n $ (&lt;)  `symmetric2` (&gt;=) -:&gt; int
--   fails n $ (&lt;=) `symmetric2` (&gt;)  -:&gt; int
--   </pre>
symmetric2 :: Eq b => (a -> a -> b) -> (a -> a -> b) -> a -> a -> Bool

-- | Is a given relation transitive?
transitive :: (a -> a -> Bool) -> a -> a -> a -> Bool

-- | An element is always related to itself.
reflexive :: (a -> a -> Bool) -> a -> Bool

-- | An element is <b>never</b> related to itself.
irreflexive :: (a -> a -> Bool) -> a -> Bool

-- | Is a given relation symmetric? This is a type-restricted version of
--   <a>commutative</a>.
symmetric :: (a -> a -> Bool) -> a -> a -> Bool

-- | Is a given relation asymmetric? Not to be confused with "not
--   symmetric" and "antissymetric".
asymmetric :: (a -> a -> Bool) -> a -> a -> Bool

-- | Is a given relation antisymmetric? Not to be confused with "not
--   symmetric" and "assymetric".
antisymmetric :: Eq a => (a -> a -> Bool) -> a -> a -> Bool

-- | Is the given binary relation an equivalence? Is the given relation
--   reflexive, symmetric and transitive?
--   
--   <pre>
--   &gt; check (equivalence (==) :: Int -&gt; Int -&gt; Int -&gt; Bool)
--   +++ OK, passed 200 tests.
--   &gt; check (equivalence (&lt;=) :: Int -&gt; Int -&gt; Int -&gt; Bool)
--   *** Failed! Falsifiable (after 3 tests):
--   0 1 0
--   </pre>
--   
--   Or, using <a>Test.LeanCheck.Utils.TypeBinding</a>:
--   
--   <pre>
--   &gt; check $ equivalence (&lt;=) -:&gt; int
--   *** Failed! Falsifiable (after 3 tests):
--   0 1 0
--   </pre>
equivalence :: (a -> a -> Bool) -> a -> a -> a -> Bool

-- | Is the given binary relation a partial order? Is the given relation
--   reflexive, antisymmetric and transitive?
partialOrder :: Eq a => (a -> a -> Bool) -> a -> a -> a -> Bool

-- | Is the given binary relation a strict partial order? Is the given
--   relation irreflexive, asymmetric and transitive?
strictPartialOrder :: (a -> a -> Bool) -> a -> a -> a -> Bool

-- | Is the given binary relation a total order?
totalOrder :: Eq a => (a -> a -> Bool) -> a -> a -> a -> Bool

-- | Is the given binary relation a strict total order?
strictTotalOrder :: Eq a => (a -> a -> Bool) -> a -> a -> a -> Bool
comparison :: (a -> a -> Ordering) -> a -> a -> a -> Bool

-- | Equal under, a ternary operator with the same fixity as <a>==</a>.
--   
--   <pre>
--   x =$ f $= y  =  f x = f y
--   </pre>
--   
--   <pre>
--   [1,2,3,4,5] =$  take 2    $= [1,2,4,8,16] -- &gt; True
--   [1,2,3,4,5] =$  take 3    $= [1,2,4,8,16] -- &gt; False
--       [1,2,3] =$    sort    $= [3,2,1]      -- &gt; True
--            42 =$ (`mod` 10) $= 16842        -- &gt; True
--            42 =$ (`mod`  9) $= 16842        -- &gt; False
--           'a' =$  isLetter  $= 'b'          -- &gt; True
--           'a' =$  isLetter  $= '1'          -- &gt; False
--   </pre>
(=$) :: Eq b => a -> (a -> b) -> a -> Bool
infixl 4 =$

-- | See <a>=$</a>
($=) :: (a -> Bool) -> a -> Bool
infixl 4 $=

-- | Check if two lists are equal for <tt>n</tt> values. This operator has
--   the same fixity of <a>==</a>.
--   
--   <pre>
--   xs =| n |= ys  =  take n xs == take n ys
--   </pre>
--   
--   <pre>
--   [1,2,3,4,5] =| 2 |= [1,2,4,8,16] -- &gt; True
--   [1,2,3,4,5] =| 3 |= [1,2,4,8,16] -- &gt; False
--   </pre>
(=|) :: Eq a => [a] -> Int -> [a] -> Bool
infixl 4 =|

-- | See <a>=|</a>
(|=) :: (a -> Bool) -> a -> Bool
infixl 4 |=
okEq :: Eq a => a -> a -> a -> Bool
okOrd :: Ord a => a -> a -> a -> Bool
okEqOrd :: (Eq a, Ord a) => a -> a -> a -> Bool
okNum :: (Eq a, Num a) => a -> a -> a -> Bool
okNumNonNegative :: (Eq a, Num a) => a -> a -> a -> Bool


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   Types to aid in property-based testing.
module Test.LeanCheck.Utils.Types

-- | Single-bit signed integers: -1, 0
newtype Int1
Int1 :: Int -> Int1
[unInt1] :: Int1 -> Int

-- | Two-bit signed integers: -2, -1, 0, 1
newtype Int2
Int2 :: Int -> Int2
[unInt2] :: Int2 -> Int

-- | Three-bit signed integers: -4, -3, -2, -1, 0, 1, 2, 3
newtype Int3
Int3 :: Int -> Int3
[unInt3] :: Int3 -> Int

-- | Four-bit signed integers: -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3,
--   4, 5, 6, 7
newtype Int4
Int4 :: Int -> Int4
[unInt4] :: Int4 -> Int

-- | Single-bit unsigned integer: 0, 1
newtype Word1
Word1 :: Int -> Word1
[unWord1] :: Word1 -> Int

-- | Two-bit unsigned integers: 0, 1, 2, 3
newtype Word2
Word2 :: Int -> Word2
[unWord2] :: Word2 -> Int

-- | Three-bit unsigned integers: 0, 1, 2, 3, 4, 5, 6, 7
newtype Word3
Word3 :: Int -> Word3
[unWord3] :: Word3 -> Int

-- | Four-bit unsigned integers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
--   13, 14, 15
newtype Word4
Word4 :: Int -> Word4
[unWord4] :: Word4 -> Int

-- | Natural numbers (including 0): 0, 1, 2, 3, 4, 5, 6, 7, ...
--   
--   Internally, this type is represented as an <a>Int</a>. So, it is
--   limited by the <a>maxBound</a> of <a>Int</a>.
--   
--   Its <a>Enum</a>, <a>Listable</a> and <a>Num</a> instances only produce
--   non-negative values. When <tt>x &lt; y</tt> then <tt>x - y = 0</tt>.
newtype Nat
Nat :: Int -> Nat
[unNat] :: Nat -> Int

-- | Natural numbers modulo 1: 0
newtype Nat1
Nat1 :: Int -> Nat1
[unNat1] :: Nat1 -> Int

-- | Natural numbers modulo 2: 0, 1
newtype Nat2
Nat2 :: Int -> Nat2
[unNat2] :: Nat2 -> Int

-- | Natural numbers modulo 3: 0, 1, 2
newtype Nat3
Nat3 :: Int -> Nat3
[unNat3] :: Nat3 -> Int

-- | Natural numbers modulo 4: 0, 1, 2, 3
newtype Nat4
Nat4 :: Int -> Nat4
[unNat4] :: Nat4 -> Int

-- | Natural numbers modulo 5: 0, 1, 2, 3, 4
newtype Nat5
Nat5 :: Int -> Nat5
[unNat5] :: Nat5 -> Int

-- | Natural numbers modulo 6: 0, 1, 2, 3, 4, 5
newtype Nat6
Nat6 :: Int -> Nat6
[unNat6] :: Nat6 -> Int

-- | Natural numbers modulo 7: 0, 1, 2, 3, 4, 5, 6
newtype Nat7
Nat7 :: Int -> Nat7
[unNat7] :: Nat7 -> Int

-- | Natural numbers (including 0): 0, 1, 2, 3, 4, 5, 6, 7, ...
--   
--   Internally, this type is represented as an <a>Integer</a> allowing for
--   an infinity of possible values.
--   
--   Its <a>Enum</a>, <a>Listable</a> and <a>Num</a> instances only produce
--   non-negative values. When <tt>x &lt; y</tt> then <tt>x - y = 0</tt>.
newtype Natural
Natural :: Integer -> Natural
[unNatural] :: Natural -> Integer

-- | Deprecated. Use <a>Word1</a>.
type UInt1 = Word1

-- | Deprecated. Use <a>Word2</a>.
type UInt2 = Word2

-- | Deprecated. Use <a>Word3</a>.
type UInt3 = Word3

-- | Deprecated. Use <a>Word4</a>.
type UInt4 = Word4

-- | <a>X</a> type to be wrapped around integer types for an
--   e-<a>X</a>-treme integer enumeration. See the <a>Listable</a> instance
--   for <a>X</a>. Use <a>X</a> when testing properties about overflows and
--   the like:
--   
--   <pre>
--   &gt; check $ \x -&gt; x + 1 &gt; (x :: Int)
--   +++ OK, passed 200 tests.
--   </pre>
--   
--   <pre>
--   &gt; check $ \(X x) -&gt; x + 1 &gt; (x :: Int)
--   +++ Failed! Falsifiable (after 4 tests):
--   9223372036854775807
--   </pre>
newtype X a
X :: a -> X a
[unX] :: X a -> a

-- | Wrap around lists of integers for an enumeration containing
--   e-<a>X</a>-treme integer values.
--   
--   <pre>
--   &gt; check $ \xs -&gt; all (&gt;=0) xs ==&gt; sum (take 1 xs :: [Int]) &lt;= sum xs
--   +++ OK, passed 200 tests.
--   </pre>
--   
--   <pre>
--   &gt; check $ \(Xs xs) -&gt; all (&gt;=0) xs ==&gt; sum (take 1 xs :: [Int]) &lt;= sum xs
--   *** Failed! Falsifiable (after 56 tests):
--   [1,9223372036854775807]
--   </pre>
newtype Xs a
Xs :: [a] -> Xs a

-- | Lists without repeated elements.
--   
--   <pre>
--   &gt; take 6 $ list :: [NoDup Nat]
--   [NoDup [],NoDup [0],NoDup [1],NoDup [0,1],NoDup [1,0],NoDup [2]]
--   </pre>
--   
--   Example, checking the property that <tt>nub</tt> is an identity:
--   
--   <pre>
--   import Data.List (nub)
--   &gt; check $ \xs -&gt; nub xs == (xs :: [Int])
--   *** Failed! Falsifiable (after 3 tests):
--   [0,0]
--   &gt; check $ \(NoDup xs) -&gt; nub xs == (xs :: [Int])
--   +++ OK, passed 200 tests.
--   </pre>
newtype NoDup a
NoDup :: [a] -> NoDup a

-- | Lists representing bags (multisets). The <a>Listable</a> <a>tiers</a>
--   enumeration will not have repeated bags.
--   
--   <pre>
--   &gt; take 6 (list :: [Bag Nat])
--   [Bag [],Bag [0],Bag [0,0],Bag [1],Bag [0,0,0],Bag [0,1]]
--   </pre>
--   
--   See also: <tt>bagsOf</tt> and <a>bagCons</a>.
newtype Bag a
Bag :: [a] -> Bag a

-- | Lists representing sets. The <a>Listable</a> <a>tiers</a> enumeration
--   will not have repeated sets.
--   
--   <pre>
--   &gt; take 6 (list :: [Set Nat])
--   [Set [],Set [0],Set [1],Set [0,1],Set [2],Set [0,2]]
--   </pre>
newtype Set a
Set :: [a] -> Set a

-- | Lists of pairs representing maps. The <a>Listable</a> <a>tiers</a>
--   enumeration will not have repeated maps.
--   
--   <pre>
--   &gt; take 6 (list :: [Map Nat Nat])
--   [Map [],Map [(0,0)],Map [(0,1)],Map [(1,0)],Map [(0,2)],Map [(1,1)]]
--   </pre>
newtype Map a b
Map :: [(a, b)] -> Map a b
data Space
Space :: Char -> Space
[unSpace] :: Space -> Char
data Lower
Lower :: Char -> Lower
[unLower] :: Lower -> Char
data Upper
Upper :: Char -> Upper
[unUpper] :: Upper -> Char
data Alpha
Alpha :: Char -> Alpha
[unAlpha] :: Alpha -> Char
data Digit
Digit :: Char -> Digit
[unDigit] :: Digit -> Char
data AlphaNum
AlphaNum :: Char -> AlphaNum
[unAlphaNum] :: AlphaNum -> Char
data Letter
Letter :: Char -> Letter
[unLetter] :: Letter -> Char
data Spaces
Spaces :: String -> Spaces
[unSpaces] :: Spaces -> String
data Lowers
Lowers :: String -> Lowers
[unLowers] :: Lowers -> String
data Uppers
Uppers :: String -> Uppers
[unUppers] :: Uppers -> String
data Alphas
Alphas :: String -> Alphas
[unAlphas] :: Alphas -> String
data Digits
Digits :: String -> Digits
[unDigits] :: Digits -> String
data AlphaNums
AlphaNums :: String -> AlphaNums
[unAlphaNums] :: AlphaNums -> String
data Letters
Letters :: String -> Letters
[unLetters] :: Letters -> String
instance GHC.Read.Read a => GHC.Read.Read (Test.LeanCheck.Utils.Types.Xs a)
instance GHC.Show.Show a => GHC.Show.Show (Test.LeanCheck.Utils.Types.Xs a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Test.LeanCheck.Utils.Types.Xs a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.LeanCheck.Utils.Types.Xs a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Test.LeanCheck.Utils.Types.X a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.LeanCheck.Utils.Types.X a)
instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Test.LeanCheck.Utils.Types.Map a b)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Test.LeanCheck.Utils.Types.Map a b)
instance (GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (Test.LeanCheck.Utils.Types.Map a b)
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Test.LeanCheck.Utils.Types.Map a b)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Test.LeanCheck.Utils.Types.Set a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.LeanCheck.Utils.Types.Set a)
instance GHC.Read.Read a => GHC.Read.Read (Test.LeanCheck.Utils.Types.Set a)
instance GHC.Show.Show a => GHC.Show.Show (Test.LeanCheck.Utils.Types.Set a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Test.LeanCheck.Utils.Types.Bag a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.LeanCheck.Utils.Types.Bag a)
instance GHC.Read.Read a => GHC.Read.Read (Test.LeanCheck.Utils.Types.Bag a)
instance GHC.Show.Show a => GHC.Show.Show (Test.LeanCheck.Utils.Types.Bag a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Test.LeanCheck.Utils.Types.NoDup a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Test.LeanCheck.Utils.Types.NoDup a)
instance GHC.Read.Read a => GHC.Read.Read (Test.LeanCheck.Utils.Types.NoDup a)
instance GHC.Show.Show a => GHC.Show.Show (Test.LeanCheck.Utils.Types.NoDup a)
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Nat7
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Nat7
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Nat6
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Nat6
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Nat5
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Nat5
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Nat4
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Nat4
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Nat3
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Nat3
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Nat2
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Nat2
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Nat1
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Nat1
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Nat
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Nat
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Natural
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Natural
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Word4
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Word4
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Word3
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Word3
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Word2
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Word2
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Word1
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Word1
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Int4
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Int4
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Int3
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Int3
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Int2
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Int2
instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.Int1
instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.Int1
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Letters
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Letters
instance GHC.Show.Show Test.LeanCheck.Utils.Types.AlphaNums
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.AlphaNums
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Digits
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Digits
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Alphas
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Alphas
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Uppers
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Uppers
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Lowers
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Lowers
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Spaces
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Spaces
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Letter
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Letter
instance GHC.Show.Show Test.LeanCheck.Utils.Types.AlphaNum
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.AlphaNum
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Digit
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Digit
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Alpha
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Alpha
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Upper
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Upper
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Lower
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Lower
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Space
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Space
instance (GHC.Real.Integral a, GHC.Enum.Bounded a) => Test.LeanCheck.Core.Listable (Test.LeanCheck.Utils.Types.Xs a)
instance GHC.Show.Show a => GHC.Show.Show (Test.LeanCheck.Utils.Types.X a)
instance (GHC.Real.Integral a, GHC.Enum.Bounded a) => Test.LeanCheck.Core.Listable (Test.LeanCheck.Utils.Types.X a)
instance (Test.LeanCheck.Core.Listable a, Test.LeanCheck.Core.Listable b) => Test.LeanCheck.Core.Listable (Test.LeanCheck.Utils.Types.Map a b)
instance Test.LeanCheck.Core.Listable a => Test.LeanCheck.Core.Listable (Test.LeanCheck.Utils.Types.Set a)
instance Test.LeanCheck.Core.Listable a => Test.LeanCheck.Core.Listable (Test.LeanCheck.Utils.Types.Bag a)
instance Test.LeanCheck.Core.Listable a => Test.LeanCheck.Core.Listable (Test.LeanCheck.Utils.Types.NoDup a)
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Nat7
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Nat7
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Nat7
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Nat7
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Nat7
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Nat7
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Nat7
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Nat7
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Nat6
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Nat6
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Nat6
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Nat6
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Nat6
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Nat6
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Nat6
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Nat6
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Nat5
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Nat5
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Nat5
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Nat5
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Nat5
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Nat5
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Nat5
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Nat5
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Nat4
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Nat4
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Nat4
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Nat4
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Nat4
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Nat4
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Nat4
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Nat4
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Nat3
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Nat3
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Nat3
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Nat3
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Nat3
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Nat3
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Nat3
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Nat3
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Nat2
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Nat2
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Nat2
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Nat2
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Nat2
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Nat2
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Nat2
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Nat2
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Nat1
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Nat1
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Nat1
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Nat1
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Nat1
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Nat1
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Nat1
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Nat1
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Nat
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Nat
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Nat
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Nat
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Nat
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Nat
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Nat
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Nat
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Natural
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Natural
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Natural
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Natural
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Natural
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Natural
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Natural
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Word4
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Word4
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Word4
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Word4
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Word4
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Word4
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Word4
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Word4
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Word3
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Word3
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Word3
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Word3
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Word3
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Word3
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Word3
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Word3
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Word2
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Word2
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Word2
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Word2
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Word2
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Word2
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Word2
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Word2
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Word1
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Word1
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Word1
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Word1
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Word1
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Word1
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Word1
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Word1
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Int4
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Int4
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Int4
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Int4
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Int4
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Int4
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Int4
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Int4
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Int3
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Int3
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Int3
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Int3
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Int3
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Int3
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Int3
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Int3
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Int2
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Int2
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Int2
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Int2
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Int2
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Int2
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Int2
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Int2
instance GHC.Show.Show Test.LeanCheck.Utils.Types.Int1
instance GHC.Read.Read Test.LeanCheck.Utils.Types.Int1
instance GHC.Num.Num Test.LeanCheck.Utils.Types.Int1
instance GHC.Real.Real Test.LeanCheck.Utils.Types.Int1
instance GHC.Real.Integral Test.LeanCheck.Utils.Types.Int1
instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.Int1
instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.Int1
instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.Int1


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   Infix operators for type binding using dummy first-class values.
--   
--   Those are useful when property based testing to avoid repetition.
--   Suppose:
--   
--   <pre>
--   prop_sortAppend :: Ord a =&gt; [a] -&gt; Bool
--   prop_sortAppend xs =  sort (xs++ys) == sort (ys++xs)
--   </pre>
--   
--   Then this:
--   
--   <pre>
--   testResults n =
--     [ holds n (prop_sortAppend :: [Int] -&gt; [Int] -&gt; Bool)
--     , holds n (prop_sortAppend :: [UInt2] -&gt; [UInt2] -&gt; Bool)
--     , holds n (prop_sortAppend :: [Bool] -&gt; [Bool] -&gt; Bool)
--     , holds n (prop_sortAppend :: [Char] -&gt; [Char] -&gt; Bool)
--     , holds n (prop_sortAppend :: [String] -&gt; [String] -&gt; Bool)
--     , holds n (prop_sortAppend :: [()] -&gt; [()] -&gt; Bool)
--     ]
--   </pre>
--   
--   Becomes this:
--   
--   <pre>
--   testResults n =
--     [ holds n $ prop_sortAppend -:&gt; [int]
--     , holds n $ prop_sortAppend -:&gt; [uint2]
--     , holds n $ prop_sortAppend -:&gt; [bool]
--     , holds n $ prop_sortAppend -:&gt; [char]
--     , holds n $ prop_sortAppend -:&gt; [string]
--     , holds n $ prop_sortAppend -:&gt; [()]
--     ]
--   </pre>
--   
--   Or even:
--   
--   <pre>
--   testResults n = concat
--     [ for int, for uint2, for bool, for (), for char, for string ]
--     where for a = [ holds n $ prop_sortAppend -:&gt; a ]
--   </pre>
--   
--   This last form is useful when testing multiple properties for multiple
--   types.
module Test.LeanCheck.Utils.TypeBinding

-- | Type restricted version of const that forces its first argument to
--   have the same type as the second. A symnonym to <a>asTypeOf</a>:
--   
--   <pre>
--   value -: ty  =  value :: Ty
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   10 -: int   =  10 :: Int
--   undefined -: 'a' &gt;- 'b'  =  undefined :: Char -&gt; Char
--   </pre>
(-:) :: a -> a -> a
infixl 1 -:

-- | Type restricted version of const that forces the argument of its first
--   argument to have the same type as the second:
--   
--   <pre>
--   f -:&gt; ty  =  f -: ty &gt;- und  =  f :: Ty -&gt; a
--   </pre>
--   
--   Example:
--   
--   <pre>
--   abs -:&gt; int   =  abs -: int &gt;- und  =  abs :: Int -&gt; Int
--   </pre>
(-:>) :: (a -> b) -> a -> a -> b
infixl 1 -:>

-- | Type restricted version of const that forces the result of its first
--   argument to have the same type as the second.
--   
--   <pre>
--   f -&gt;: ty  =  f -: und &gt;- ty  =  f :: a -&gt; Ty
--   </pre>
(->:) :: (a -> b) -> b -> a -> b
infixl 1 ->:

-- | Type restricted version of const that forces the second argument of
--   its first argument to have the same type as the second.
--   
--   <pre>
--   f -&gt;:&gt; ty   =  f -: und -&gt; ty -&gt; und  =  f :: a -&gt; Ty -&gt; b
--   </pre>
(->:>) :: (a -> b -> c) -> b -> a -> b -> c
infixl 1 ->:>

-- | Type restricted version of const that forces the result of the result
--   of its first argument to have the same type as the second.
--   
--   <pre>
--   f -&gt;&gt;: ty   =  f -: und -&gt; und -&gt; ty  =  f :: a -&gt; b -&gt; Ty
--   </pre>
(->>:) :: (a -> b -> c) -> c -> a -> b -> c
infixl 1 ->>:

-- | Type restricted version of const that forces the third argument of its
--   first argument to have the same type as the second.
(->>:>) :: (a -> b -> c -> d) -> c -> a -> b -> c -> d
infixl 1 ->>:>

-- | Type restricted version of const that forces the result of the result
--   of the result of its first argument to have the same type as the
--   second.
(->>>:) :: (a -> b -> c -> d) -> d -> a -> b -> c -> d
infixl 1 ->>>:

-- | Forces the 4th argument type.
(->>>:>) :: (a -> b -> c -> d -> e) -> d -> a -> b -> c -> d -> e
infixl 1 ->>>:>

-- | Forces the result type of a 4-argument function.
(->>>>:) :: (a -> b -> c -> d -> e) -> e -> a -> b -> c -> d -> e
infixl 1 ->>>>:

-- | Forces the 5th argument type.
(->>>>:>) :: (a -> b -> c -> d -> e -> f) -> e -> a -> b -> c -> d -> e -> f
infixl 1 ->>>>:>

-- | Forces the result type of a 5-argument function.
(->>>>>:) :: (a -> b -> c -> d -> e -> f) -> f -> a -> b -> c -> d -> e -> f
infixl 1 ->>>>>:

-- | Forces the 6th argument type.
(->>>>>:>) :: (a -> b -> c -> d -> e -> f -> g) -> f -> a -> b -> c -> d -> e -> f -> g
infixl 1 ->>>>>:>

-- | Forces the result type of a 6-argument function.
(->>>>>>:) :: (a -> b -> c -> d -> e -> f -> g) -> g -> a -> b -> c -> d -> e -> f -> g
infixl 1 ->>>>>>:

-- | Forces the 7th argument type.
(->>>>>>:>) :: (a -> b -> c -> d -> e -> f -> g -> h) -> g -> a -> b -> c -> d -> e -> f -> g -> h
infixl 1 ->>>>>>:>

-- | Forces the result type of a 7-argument function.
(->>>>>>>:) :: (a -> b -> c -> d -> e -> f -> g -> h) -> h -> a -> b -> c -> d -> e -> f -> g -> h
infixl 1 ->>>>>>>:

-- | Forces the 8th argument type.
(->>>>>>>:>) :: (a -> b -> c -> d -> e -> f -> g -> h -> i) -> h -> a -> b -> c -> d -> e -> f -> g -> h -> i
infixl 1 ->>>>>>>:>

-- | Forces the result type of a 8-argument function.
(->>>>>>>>:) :: (a -> b -> c -> d -> e -> f -> g -> h -> i) -> i -> a -> b -> c -> d -> e -> f -> g -> h -> i
infixl 1 ->>>>>>>>:

-- | Forces the 9th argument type.
(->>>>>>>>:>) :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> i -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j
infixl 1 ->>>>>>>>:>

-- | Forces the result type of a 9-argument function.
(->>>>>>>>>:) :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> j -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j
infixl 1 ->>>>>>>>>:

-- | Forces the type of the 10th argument.
(->>>>>>>>>:>) :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> j -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
infixl 1 ->>>>>>>>>:>

-- | Forces the result type of a 10-argument function.
(->>>>>>>>>>:) :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> k -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
infixl 1 ->>>>>>>>>>:

-- | Forces the type of the 11th argument.
(->>>>>>>>>>:>) :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) -> k -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
infixl 1 ->>>>>>>>>>:>

-- | Forces the result type of a 11-argument function.
(->>>>>>>>>>>:) :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) -> l -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l
infixl 1 ->>>>>>>>>>>:

-- | Forces the type of the 12th argument.
(->>>>>>>>>>>:>) :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) -> m -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
infixl 1 ->>>>>>>>>>>:>

-- | Forces the result type of a 12-argument function.
(->>>>>>>>>>>>:) :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) -> m -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m
infixl 1 ->>>>>>>>>>>>:

-- | Shorthand for undefined
und :: a

-- | Returns an undefined functional value that takes an argument of the
--   type of its first argument and return a value of the type of its
--   second argument.
--   
--   <pre>
--   ty &gt;- ty  =  (undefined :: Ty -&gt; Ty)
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   'a' &gt;- 'b'  =  char &gt;- char  =  (undefined :: Char -&gt; Char)
--   int &gt;- bool &gt;- int  =  undefined :: Int -&gt; Bool -&gt; Int
--   </pre>
(>-) :: a -> b -> a -> b
infixr 9 >-

-- | Undefined <a>Bool</a> value.
bool :: Bool

-- | Undefined <a>Int</a> value for use with type binding operators.
--   
--   <pre>
--   check $ (\x y -&gt; x + y == y + x) -&gt;:&gt; int
--   </pre>
int :: Int

-- | Undefined <a>Integer</a> value for use with type binding operators.
--   
--   <pre>
--   check $ (\x y -&gt; x + y == y + x) -&gt;:&gt; integer
--   </pre>
integer :: Integer

-- | Undefined <a>Float</a> value for use with type binding operators.
float :: Float

-- | Undefined <a>Double</a> value for use with type binding operators.
double :: Double

-- | Undefined <a>Rational</a> value for use with type binding operators.
rational :: Rational

-- | Undefined <a>Char</a> value.
char :: Char

-- | Undefined <a>String</a> value.
string :: String

-- | Undefined <a>Ordering</a> value.
ordering :: Ordering

-- | Undefined <a>Maybe</a> value. Uses the type of the given value as the
--   argument type. For use with type binding operators.
--   
--   To check a property with the first argument bound to <a>Maybe</a>
--   <a>Int</a>, do:
--   
--   <pre>
--   check $ prop -:&gt; mayb int
--   </pre>
mayb :: a -> Maybe a

-- | Undefined <a>Either</a> value. Uses the types of the given values as
--   the argument types. For use with type binding operators.
eith :: a -> b -> Either a b

-- | Undefined <a>Natural</a> value.
natural :: Natural

-- | Undefined <a>Nat</a> value.
nat :: Nat

-- | Undefined <a>Int1</a> value.
int1 :: Int1

-- | Undefined <a>Int2</a> value.
int2 :: Int2

-- | Undefined <a>Int3</a> value.
int3 :: Int3

-- | Undefined <a>Int4</a> value.
int4 :: Int4

-- | Undefined <a>Word1</a> value.
word1 :: Word1

-- | Undefined <a>Word2</a> value.
word2 :: Word2

-- | Undefined <a>Word3</a> value.
word3 :: Word3

-- | Undefined <a>Word4</a> value.
word4 :: Word4

-- | Deprecated. Use <a>word1</a>.
uint1 :: UInt1

-- | Deprecated. Use <a>word2</a>.
uint2 :: UInt2

-- | Deprecated. Use <a>word3</a>.
uint3 :: UInt3

-- | Deprecated. Use <a>word4</a>.
uint4 :: UInt4


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   Some utilities for property-based testing with <a>LeanCheck</a>.
--   
--   Those utilities are general-purpose enough to be used with other
--   property-based based testing libraries. See each exported module for
--   details.
--   
--   This is not exported by <a>Test.LeanCheck</a>. You need to import this
--   explicitly.
module Test.LeanCheck.Utils


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports the <a>ShowFunction</a> typeclass, its instances
--   and related functions.
--   
--   Using this module, it is possible to implement a <a>Show</a> instance
--   for functions:
--   
--   <pre>
--   import Test.LeanCheck.ShowFunction
--   instance (Show a, Listable a, ShowFunction b) =&gt; Show (a-&gt;b) where
--     show = showFunction 8
--   </pre>
--   
--   This shows functions as a case pattern with up to 8 cases.
--   
--   It will only work for functions whose ultimate return value is an
--   instance of <a>ShowFunction</a>. This module provides instances for
--   most standard data types (<a>Int</a>, <a>Bool</a>, <a>Maybe</a>, ...).
--   Please see the <a>ShowFunction</a> typeclass documentation for how to
--   declare istances for user-defined data types.
--   
--   The modules <a>Test.LeanCheck.Function</a> and
--   <a>Test.LeanCheck.Function.Show</a> exports an instance like the one
--   above.
module Test.LeanCheck.Function.ShowFunction

-- | Given the number of patterns to show, shows a <a>ShowFunction</a>
--   value.
--   
--   <pre>
--   &gt; putStrLn $ showFunction undefined True
--   True
--   
--   &gt; putStrLn $ showFunction 3 (id::Int-&gt;Int)
--   \x -&gt; case x of
--         0 -&gt; 0
--         1 -&gt; 1
--         -1 -&gt; -1
--         ...
--   
--   &gt; putStrLn $ showFunction 4 (&amp;&amp;)
--   \x y -&gt; case (x,y) of
--           (True,True) -&gt; True
--           _ -&gt; False
--   </pre>
--   
--   In the examples above, "<tt>...</tt>" should be interpreted literally.
--   
--   This can be used as an implementation of <a>show</a> for functions:
--   
--   <pre>
--   instance (Show a, Listable a, ShowFunction b) =&gt; Show (a-&gt;b) where
--     show = showFunction 8
--   </pre>
--   
--   See <a>showFunctionLine</a> for an alternative without line breaks.
showFunction :: ShowFunction a => Int -> a -> String

-- | Same as <a>showFunction</a>, but has no line breaks.
--   
--   <pre>
--   &gt; putStrLn $ showFunctionLine 3 (id::Int-&gt;Int)
--   \x -&gt; case x of 0 -&gt; 0; 1 -&gt; 1; -1 -&gt; -1; ...
--   &gt; putStrLn $ showFunctionLine 3 (&amp;&amp;)
--   \x y -&gt; case (x,y) of (True,True) -&gt; True; _ -&gt; False
--   </pre>
--   
--   This can be used as an implementation of <a>show</a> for functions:
--   
--   <pre>
--   instance (Show a, Listable a, ShowFunction b) =&gt; Show (a-&gt;b) where
--     show = showFunction 8
--   </pre>
showFunctionLine :: ShowFunction a => Int -> a -> String

-- | <a>ShowFunction</a> values are those for which we can return a list of
--   functional bindings.
--   
--   Instances for <a>show</a>able algebraic datatypes are defined using
--   <a>bindtiersShow</a>:
--   
--   <pre>
--   instance ShowFunction Ty where bindtiers = bindtiersShow
--   </pre>
class ShowFunction a
bindtiers :: ShowFunction a => a -> [[Binding]]

-- | A drop-in implementation of <a>bindtiers</a> for <a>show</a>able
--   types.
--   
--   Define instances for <a>show</a>able algebraic datatypes as:
--   
--   <pre>
--   instance ShowFunction Ty where bindtiers = bindtiersShow
--   </pre>
bindtiersShow :: Show a => a -> [[Binding]]

-- | A functional binding in a showable format. Argument values are
--   represented as a list of strings. The result value is represented by
--   <a>Just</a> a <a>String</a> when defined or by <a>Nothing</a> when
--   <a>undefined</a>.
type Binding = ([String], Maybe String)

-- | Given a <a>ShowFunction</a> value, return a list of <a>Binding</a>s.
--   If the domain of the given argument function is infinite, the
--   resulting list is infinite.
--   
--   Some examples follow. These are used as running examples in the
--   definition of <a>explainedBindings</a>, <a>describedBindings</a> and
--   <a>clarifiedBindings</a>.
--   
--   <ul>
--   <li>Defined return values are represented as <a>Just</a>
--   <a>String</a>s:<pre>&gt; bindings True [([],Just "True")]</pre></li>
--   <li>Undefined return values are represented as
--   <tt>Nothing</tt>:<pre>&gt; bindings undefined
--   [([],Nothing)]</pre></li>
--   <li>Infinite domains result in an infinite bindings list:<pre>&gt;
--   bindings (id::Int-&gt;Int) [ (["0"], Just "0") , (["1"], Just "1") ,
--   (["-1"], Just "-1") , ... ]</pre></li>
--   <li>Finite domains result in a finite bindings list:<pre>&gt; bindings
--   (&amp;&amp;) [ (["False","False"], Just "False") , (["False","True"],
--   Just "False") , (["True","False"], Just "False") , (["True","True"],
--   Just "True") ]</pre><pre>&gt; bindings (||) [ (["False","False"], Just
--   "False") , (["False","True"], Just "True") , (["True","False"], Just
--   "True") , (["True","True"], Just "True") ]</pre></li>
--   <li>Even very simple functions are represented by an infinite list of
--   bindings:<pre>&gt; bindings (== 0) [ (["0"], Just "True") , (["1"],
--   Just "False") , (["-1"], Just "False") , ... ]</pre><pre>&gt; bindings
--   (== 1) [ (["0"], Just "False") , (["1"], Just "True") , (["-1"], Just
--   "False") , ... ]</pre></li>
--   <li>Ignored arguments are still listed:<pre>&gt; bindings ((\_ y -&gt;
--   y == 1) :: Int -&gt; Int -&gt; Bool) [ (["0","0"], Just "False") ,
--   (["0","1"], Just "True") , (["1","0"], Just "False") , ...
--   ]</pre></li>
--   <li>Again, undefined values are represented as <a>Nothing</a>. Here,
--   the <a>head</a> of an empty list is undefined:<pre>&gt; bindings (head
--   :: [Int] -&gt; Int) [ (["[]"], Nothing) , (["[0]"], Just "0") ,
--   (["[0,0]"], Just "0") , (["[1]"], Just "1") , ... ]</pre></li>
--   </ul>
bindings :: ShowFunction a => a -> [Binding]

-- | Returns a set of bindings explaining how a function works. Some
--   argument values are generalized to "<tt>_</tt>" when possible. It
--   takes as argument the maximum number of cases considered for computing
--   the explanation.
--   
--   A measure of success in this generalization process is if this
--   function returns less values than the asked maximum number of cases.
--   
--   This is the <i>first</i> function in the clarification pipeline.
--   
--   <ul>
--   <li>In some cases, <a>bindings</a> cannot be "explained" an almost
--   unchanged result of <a>bindings</a> is returned with the last binding
--   having variables replaced by "<tt>_</tt>":<pre>&gt; explainedBindings
--   4 (id::Int-&gt;Int) [ (["0"],Just "0") , (["1"],Just "1") ,
--   (["-1"],Just "-1") , (["_"],Just "2") ]</pre></li>
--   <li>When possible, some cases are generalized using
--   <tt>_</tt>:<pre>&gt; explainedBindings 10 (||) [
--   (["False","False"],Just "False") , (["_","_"],Just "True") ]</pre>but
--   the resulting "explanation" might not be the shortest possible (cf.
--   <a>describedBindings</a>):<pre>&gt; explainedBindings 10 (&amp;&amp;)
--   [ ( ["False","_"],Just "False") , (["_","False"],Just "False") ,
--   (["_","_"],Just "True") ]</pre></li>
--   <li>Generalization works for infinite domains
--   (heuristically):<pre>&gt; explainedBindings 10 (==0) [ (["0"],Just
--   "True") , (["_"],Just "False") ]</pre></li>
--   <li>Generalization for each item is processed in the order they are
--   generated by <a>bindings</a> hence explanations are not always the
--   shortest possible (cf. <a>describedBindings</a>). In the following
--   examples, the first case is redundant.<pre>&gt; explainedBindings 10
--   (==1) [ (["0"],Just "False") , (["1"],Just "True"), , (["_"],Just
--   "False") ]</pre><pre>&gt; explainedBindings 10 (\_ y -&gt; y == 1) [
--   (["_","0"],Just "False") , (["_","1"],Just "True") , (["_","_"],Just
--   "False") ]</pre></li>
--   </ul>
explainedBindings :: ShowFunction a => Int -> a -> [Binding]

-- | Returns a set of bindings describing how a function works. Some
--   argument values are generalized to "<tt>_</tt>" when possible. It
--   takes two integer arguments:
--   
--   <ol>
--   <li><tt>m</tt>: the maximum number of cases considered for computing
--   description;</li>
--   <li><tt>n</tt>: the maximum number of cases in the actual
--   description.</li>
--   </ol>
--   
--   As a general rule of thumb, set <tt>m=n*n+1</tt>.
--   
--   This is the <i>second</i> function in the clarification pipeline.
--   
--   This function processes the result of <a>explainedBindings</a> to
--   sometimes return shorter descriptions. It chooses the shortest of the
--   following (in order):
--   
--   <ul>
--   <li>regular unexplained-undescribed <a>bindings</a>;</li>
--   <li>regular <a>explainedBindings</a>;</li>
--   <li><a>explainedBindings</a> with least occurring cases generalized
--   first;</li>
--   </ul>
--   
--   Here are some examples:
--   
--   <ul>
--   <li>Sometimes the result is the same as
--   <a>explainedBindings</a>:<pre>&gt; describedBindings 100 10 (||) [
--   (["False","False"],Just "False") , (["_","_"],Just "True")
--   ]</pre><pre>&gt; describedBindings 100 10 (==0) [ (["0"],Just "True")
--   , (["_"],Just "False") ]</pre></li>
--   <li>but sometimes it is shorter because we consider generalizing least
--   occurring cases first:<pre>&gt; describedBindings 100 10 (&amp;&amp;)
--   [ ( ["True","True"],Just "True") , ( ["_","_"],Just "False")
--   ]</pre><pre>&gt; describedBindings 100 10 (==1) [ (["1"],Just "True"),
--   , (["_"],Just "False") ]</pre><pre>&gt; describedBindings 100 10 (\_ y
--   -&gt; y == 1) [ (["_","1"],Just "True") , (["_","_"],Just "False")
--   ]</pre></li>
--   </ul>
describedBindings :: ShowFunction a => Int -> Int -> a -> [Binding]

-- | Returns a set of variables and a set of bindings describing how a
--   function works.
--   
--   Some argument values are generalized to "<tt>_</tt>" when possible. If
--   one of the function arguments is not used altogether, it is ommited in
--   the set of bindings and appears as "_" in the variables list.
--   
--   This is the <i>last</i> function in the clarification pipeline.
--   
--   It takes two integer arguments:
--   
--   <ol>
--   <li><tt>m</tt>: the maximum number of cases considered for computing
--   the description;</li>
--   <li><tt>n</tt>: the maximum number of cases in the actual
--   description.</li>
--   </ol>
--   
--   As a general rule of thumb, set <tt>m=n*n+1</tt>.
--   
--   Some examples follow:
--   
--   <ul>
--   <li>When all arguments are used, the result is the same as
--   <a>describedBindings</a>:<pre>&gt; clarifiedBindings 100 10 (==1) (
--   ["x"], [ (["1"],Just "True"), , (["_"],Just "False") ] )</pre></li>
--   <li>When some arguments are unused, they are omitted in the list of
--   bindings and appear as <tt>"_"</tt> in the list of variables.<pre>&gt;
--   clarifiedBindings 100 10 (\_ y -&gt; y == 1) ( ["_", "y"], [
--   (["1"],Just "True") , (["_"],Just "False") ] )</pre></li>
--   </ul>
clarifiedBindings :: ShowFunction a => Int -> Int -> a -> ([String], [Binding])

-- | A type is <a>Listable</a> when there exists a function that is able to
--   list (ideally all of) its values.
--   
--   Ideally, instances should be defined by a <a>tiers</a> function that
--   returns a (potentially infinite) list of finite sub-lists (tiers): the
--   first sub-list contains elements of size 0, the second sub-list
--   contains elements of size 1 and so on. Size here is defined by the
--   implementor of the type-class instance.
--   
--   For algebraic data types, the general form for <a>tiers</a> is
--   
--   <pre>
--   tiers = cons&lt;N&gt; ConstructorA
--        \/ cons&lt;N&gt; ConstructorB
--        \/ ...
--        \/ cons&lt;N&gt; ConstructorZ
--   </pre>
--   
--   where <tt>N</tt> is the number of arguments of each constructor
--   <tt>A...Z</tt>.
--   
--   Here is a datatype with 4 constructors and its listable instance:
--   
--   <pre>
--   data MyType  =  MyConsA
--                |  MyConsB Int
--                |  MyConsC Int Char
--                |  MyConsD String
--   
--   instance Listable MyType where
--     tiers =  cons0 MyConsA
--           \/ cons1 MyConsB
--           \/ cons2 MyConsC
--           \/ cons1 MyConsD
--   </pre>
--   
--   The instance for Hutton's Razor is given by:
--   
--   <pre>
--   data Expr  =  Val Int
--              |  Add Expr Expr
--   
--   instance Listable Expr where
--     tiers  =  cons1 Val
--            \/ cons2 Add
--   </pre>
--   
--   Instances can be alternatively defined by <a>list</a>. In this case,
--   each sub-list in <a>tiers</a> is a singleton list (each succeeding
--   element of <a>list</a> has +1 size).
--   
--   The function <a>deriveListable</a> from <a>Test.LeanCheck.Derive</a>
--   can automatically derive instances of this typeclass.
--   
--   A <a>Listable</a> instance for functions is also available but is not
--   exported by default. Import <a>Test.LeanCheck.Function</a> if you need
--   to test higher-order properties.
class Listable a
instance Test.LeanCheck.Function.ShowFunction.ShowFunction ()
instance Test.LeanCheck.Function.ShowFunction.ShowFunction GHC.Types.Bool
instance Test.LeanCheck.Function.ShowFunction.ShowFunction GHC.Types.Int
instance Test.LeanCheck.Function.ShowFunction.ShowFunction GHC.Integer.Type.Integer
instance Test.LeanCheck.Function.ShowFunction.ShowFunction GHC.Types.Char
instance Test.LeanCheck.Function.ShowFunction.ShowFunction GHC.Types.Float
instance Test.LeanCheck.Function.ShowFunction.ShowFunction GHC.Types.Double
instance Test.LeanCheck.Function.ShowFunction.ShowFunction GHC.Types.Ordering
instance GHC.Show.Show a => Test.LeanCheck.Function.ShowFunction.ShowFunction [a]
instance GHC.Show.Show a => Test.LeanCheck.Function.ShowFunction.ShowFunction (GHC.Maybe.Maybe a)
instance (GHC.Show.Show a, GHC.Show.Show b) => Test.LeanCheck.Function.ShowFunction.ShowFunction (Data.Either.Either a b)
instance (GHC.Show.Show a, GHC.Show.Show b) => Test.LeanCheck.Function.ShowFunction.ShowFunction (a, b)
instance (GHC.Show.Show a, Test.LeanCheck.Core.Listable a, Test.LeanCheck.Function.ShowFunction.ShowFunction b) => Test.LeanCheck.Function.ShowFunction.ShowFunction (a -> b)
instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c) => Test.LeanCheck.Function.ShowFunction.ShowFunction (a, b, c)
instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c, GHC.Show.Show d) => Test.LeanCheck.Function.ShowFunction.ShowFunction (a, b, c, d)
instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c, GHC.Show.Show d, GHC.Show.Show e) => Test.LeanCheck.Function.ShowFunction.ShowFunction (a, b, c, d, e)
instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c, GHC.Show.Show d, GHC.Show.Show e, GHC.Show.Show f) => Test.LeanCheck.Function.ShowFunction.ShowFunction (a, b, c, d, e, f)
instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c, GHC.Show.Show d, GHC.Show.Show e, GHC.Show.Show f, GHC.Show.Show g) => Test.LeanCheck.Function.ShowFunction.ShowFunction (a, b, c, d, e, f, g)
instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c, GHC.Show.Show d, GHC.Show.Show e, GHC.Show.Show f, GHC.Show.Show g, GHC.Show.Show h) => Test.LeanCheck.Function.ShowFunction.ShowFunction (a, b, c, d, e, f, g, h)
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Nat
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Nat1
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Nat2
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Nat3
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Nat4
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Nat5
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Nat6
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Nat7
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Int1
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Int2
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Int3
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Int4
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Word1
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Word2
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Word3
instance Test.LeanCheck.Function.ShowFunction.ShowFunction Test.LeanCheck.Utils.Types.Word4


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports an orphan <a>Show</a> instance for functions. It
--   shows functions as up to 4 case distinctions in a single line.
--   
--   Please see <a>Test.LeanCheck.Function.Show.EightLines</a> for an
--   alternative that shows functions as up to 8 case distinctions, one per
--   line.
--   
--   The <a>Show</a> '-&gt;' instance only works for functions of which
--   ultimate return types are instances of the <a>ShowFunction</a>
--   typeclass. Please see <a>Test.LeanCheck.Function.ShowFunction</a> for
--   how to define these instances for your user-defined algebraic
--   datatypes.
--   
--   Warning: this is only intended to be used in testing modules. Avoid
--   importing this on modules that are used as libraries.
module Test.LeanCheck.Function.Show.FourCases
instance (GHC.Show.Show a, Test.LeanCheck.Core.Listable a, Test.LeanCheck.Function.ShowFunction.ShowFunction b) => GHC.Show.Show (a -> b)


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports an orphan <a>Show</a> instance for functions. It
--   shows functions as up to 8 case distinctions, one per line.
--   
--   Please see <a>Test.LeanCheck.Function.Show.FourCases</a> for an
--   alternative that shows functions as up to 4 case distinctions in a
--   single line.
--   
--   The <a>Show</a> '-&gt;' instance only works for functions of which
--   ultimate return types are instances of the <a>ShowFunction</a>
--   typeclass. Please see <a>Test.LeanCheck.Function.ShowFunction</a> for
--   how to define these instances for your user-defined algebraic
--   datatypes.
--   
--   Warning: this is only intended to be used in testing modules. Avoid
--   importing this on modules that are used as libraries.
module Test.LeanCheck.Function.Show.EightLines
instance (GHC.Show.Show a, Test.LeanCheck.Core.Listable a, Test.LeanCheck.Function.ShowFunction.ShowFunction b) => GHC.Show.Show (a -> b)


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports an orphan <a>Show</a> instance for functions. It
--   shows functions as up to 8 case distinctions, one per line.
--   
--   <i>Warning: this is only intended to be used in testing modules.</i>
--   <i>Avoid importing this on modules that are used as libraries.</i>
--   
--   This is intended to <a>Show</a> functions generated by the
--   <tt>Listable</tt> instance for functions defined in
--   <a>Test.LeanCheck.Function.Listable</a>: functions that have finite
--   exceptions to a constant function. It does work on other types of
--   functions, albeit using <tt>"..."</tt>.
--   
--   <pre>
--   &gt; print (&amp;&amp;)
--   \x y -&gt; case (x,y) of
--           (True,True) -&gt; True
--           _ -&gt; False
--   </pre>
--   
--   <pre>
--   &gt; print (==&gt;)
--   \x y -&gt; case (x,y) of
--           (True,False) -&gt; False
--           _ -&gt; True
--   </pre>
--   
--   <pre>
--   &gt; print (==2)
--   \x -&gt; case x of
--         2 -&gt; True
--         _ -&gt; False
--   </pre>
--   
--   <pre>
--   &gt; print (\x -&gt; abs x &lt; 2)
--   \x -&gt; case x of
--         0 -&gt; True
--         1 -&gt; True
--         -1 -&gt; True
--         _ -&gt; False
--   </pre>
--   
--   When the function cannot be defined by finite exceptions to a constant
--   function using 8 case-patterns, the rest of the function is
--   represented by <tt>"..."</tt>.
--   
--   <pre>
--   &gt; print (+)
--   \x y -&gt; case (x,y) of
--           (0,0) -&gt; 0
--           (0,1) -&gt; 1
--           (1,0) -&gt; 1
--           (0,-1) -&gt; -1
--           (1,1) -&gt; 2
--           (-1,0) -&gt; -1
--           (0,2) -&gt; 2
--           (1,-1) -&gt; 0
--           ...
--   </pre>
--   
--   The exported orphan <a>Show</a> '-&gt;' instance is actually defined
--   in <a>Test.LeanCheck.Function.Show.EightLines</a>. An alternative is
--   provided in <a>Test.LeanCheck.Function.Show.FourCases</a>.
--   
--   The exported <a>Show</a> instance only works for functions whose
--   ultimate return types are instances of <a>ShowFunction</a>. For
--   user-defined algebraic datatypes that are instances of <a>Show</a>,
--   their ShowFunction instance can be defined by using
--   <a>bindtiersShow</a>:
--   
--   <pre>
--   import Test.LeanCheck.Function.ShowFunction
--   
--   instance ShowFunction Ty where
--     bindtiers = bindtiersShow
--   </pre>
module Test.LeanCheck.Function.Show


-- | This module is part of LeanCheck, a simple enumerative property-based
--   testing library.
--   
--   This module exports <a>Listable</a> and <a>Show</a> function typeclass
--   instances. These can be useful for testing higher-order properties ---
--   properties that take functions as arguments.
--   
--   <pre>
--   &gt; import Test.LeanCheck
--   &gt; import Test.LeanCheck.Function
--   </pre>
--   
--   <pre>
--   &gt; check $ \f p xs -&gt; filter p (map f xs) == map f (filter p xs :: [Int])
--   *** Failed! Falsifiable (after 36 tests):
--   \_ -&gt; 0
--   \x -&gt; case x of
--         0 -&gt; True
--         _ -&gt; False
--   [1]
--   </pre>
--   
--   <pre>
--   &gt; check $ \f p xs -&gt; filter p (map f xs) == map f (filter p xs :: [Bool])
--   *** Failed! Falsifiable (after 20 tests):
--   \_ -&gt; False
--   \x -&gt; case x of
--         False -&gt; False
--         True -&gt; True
--   [True]
--   </pre>
--   
--   <pre>
--   &gt; check $ \f z xs -&gt; foldr f z xs == foldl f z (xs :: [Int])
--   *** Failed! Falsifiable (after 75 tests):
--   \x _ -&gt; case x of
--           0 -&gt; 1
--           _ -&gt; 0
--   0
--   [0,0]
--   </pre>
--   
--   Warning: this is only intended to be used in testing modules. Avoid
--   importing this on modules that are used as libraries.
module Test.LeanCheck.Function
