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


-- | Functional Enumeration of Algebraic Types
--   
--   Feat (Functional Enumeration of Algebraic Types) provides enumerations
--   as functions from natural numbers to values (similar to
--   <tt>toEnum</tt> but for any algebraic data type). This can be used for
--   SmallCheck-style systematic testing, QuickCheck style random testing,
--   and hybrids of the two.
--   
--   The enumerators are defined in a very boilerplate manner and there is
--   a Template Haskell script for deriving the class instance for most
--   types. <a>Test.Feat</a> contain a subset of the other modules that
--   should be sufficient for most test usage. There are some small and
--   large example in the tar ball.
--   
--   The generators are provided by the size-based package. This means
--   other libraries that implement the Sized class can use the same
--   generator definitions. One such is the <a>lazy-search package</a>,
--   that uses laziness to search for values and test properties. This is
--   typically a lot faster than Feat for properties that have
--   preconditions (logical implication), but can not be used for random
--   selection of values.
@package testing-feat
@version 1.1.0.0


-- | <i>Deprecated: Use Control.Enumerable instead</i>
module Test.Feat.Class
class Typeable a => Enumerable a
enumerate :: (Enumerable a, Typeable f, Sized f) => Shared f a
nullary :: Sized f => a -> Shareable f a
unary :: (Enumerable a, Sized f, Typeable f) => a -> x -> Shareable f x
funcurry :: () => a -> b -> c -> (a, b) -> c
shared :: (Sized f, Enumerable a, Typeable f) => Shareable f a
consts :: (Sized f, Typeable f, Typeable a) => [Shareable f a] -> Shared f a
deriveEnumerable :: Name -> Q [Dec]


-- | A datatype of finite sequences
module Test.Feat.Finite
data Finite a
Finite :: Index -> Index -> a -> Finite a
[fCard] :: Finite a -> Index
[fIndex] :: Finite a -> Index -> a
type Index = Integer
fromFinite :: Finite a -> (Index, [a])
finFin :: Integer -> Finite Integer
instance GHC.Base.Functor Test.Feat.Finite.Finite
instance GHC.Base.Applicative Test.Feat.Finite.Finite
instance GHC.Base.Alternative Test.Feat.Finite.Finite
instance GHC.Base.Semigroup (Test.Feat.Finite.Finite a)
instance GHC.Base.Monoid (Test.Feat.Finite.Finite a)
instance GHC.Show.Show a => GHC.Show.Show (Test.Feat.Finite.Finite a)


-- | Basic combinators for building enumerations most users will want to
--   use the type class based combinators in <a>Test.Feat.Class</a>
--   instead.
module Test.Feat.Enumerate
type Index = Integer

-- | A functional enumeration of type <tt>t</tt> is a partition of
--   <tt>t</tt> into finite numbered sets called Parts. Each parts contains
--   values of a certain cost (typically the size of the value).
data Enumerate a
Enumerate :: RevList (Finite a) -> Enumerate a
[revParts] :: Enumerate a -> RevList (Finite a)
parts :: Enumerate a -> [Finite a]
fromParts :: [Finite a] -> Enumerate a

-- | A data structure that contains a list and the reversals of all initial
--   segments of the list. Intuitively
--   
--   <pre>
--   reversals xs !! n = reverse (take (n+1) (fromRev xs))
--   </pre>
--   
--   Any operation on a <tt>RevList</tt> typically discards the reversals
--   and constructs new reversals on demand.
data RevList a
RevList :: [a] -> [[a]] -> RevList a
[fromRev] :: RevList a -> [a]
[reversals] :: RevList a -> [[a]]

-- | Constructs a "Reverse list" variant of a given list. In a sensible
--   Haskell implementation evaluating any inital segment of
--   <tt><a>reversals</a> (toRev xs)</tt> uses linear memory in the size of
--   the segment.
toRev :: [a] -> RevList a
data Finite a
Finite :: Index -> Index -> a -> Finite a
[fCard] :: Finite a -> Index
[fIndex] :: Finite a -> Index -> a
fromFinite :: Finite a -> (Index, [a])

-- | The class of monoids (types with an associative binary operation that
--   has an identity). Instances should satisfy the following laws:
--   
--   <ul>
--   <li><pre>x <a>&lt;&gt;</a> <a>mempty</a> = x</pre></li>
--   <li><pre><a>mempty</a> <a>&lt;&gt;</a> x = x</pre></li>
--   <li><tt>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) = (x <a>&lt;&gt;</a>
--   y) <a>&lt;&gt;</a> z</tt> (<a>Semigroup</a> law)</li>
--   <li><pre><a>mconcat</a> = <a>foldr</a> '(&lt;&gt;)'
--   <a>mempty</a></pre></li>
--   </ul>
--   
--   The method names refer to the monoid of lists under concatenation, but
--   there are many other instances.
--   
--   Some types can be viewed as a monoid in more than one way, e.g. both
--   addition and multiplication on numbers. In such cases we often define
--   <tt>newtype</tt>s and make those instances of <a>Monoid</a>, e.g.
--   <tt>Sum</tt> and <tt>Product</tt>.
--   
--   <b>NOTE</b>: <a>Semigroup</a> is a superclass of <a>Monoid</a> since
--   <i>base-4.11.0.0</i>.
class Semigroup a => Monoid a

-- | Identity of <a>mappend</a>
mempty :: Monoid a => a

-- | An associative operation
--   
--   <b>NOTE</b>: This method is redundant and has the default
--   implementation <tt><a>mappend</a> = '(&lt;&gt;)'</tt> since
--   <i>base-4.11.0.0</i>.
mappend :: Monoid a => a -> a -> a

-- | Fold a list using the monoid.
--   
--   For most types, the default definition for <a>mconcat</a> will be
--   used, but the function is included in the class definition so that an
--   optimized version can be provided for specific types.
mconcat :: Monoid a => [a] -> a

-- | Maybe monoid returning the leftmost non-Nothing value.
--   
--   <tt><a>First</a> a</tt> is isomorphic to <tt><a>Alt</a> <a>Maybe</a>
--   a</tt>, but precedes it historically.
--   
--   <pre>
--   &gt;&gt;&gt; getFirst (First (Just "hello") &lt;&gt; First Nothing &lt;&gt; First (Just "world"))
--   Just "hello"
--   </pre>
newtype First a
First :: Maybe a -> First a
[getFirst] :: First a -> Maybe a

-- | Maybe monoid returning the rightmost non-Nothing value.
--   
--   <tt><a>Last</a> a</tt> is isomorphic to <tt><a>Dual</a> (<a>First</a>
--   a)</tt>, and thus to <tt><a>Dual</a> (<a>Alt</a> <a>Maybe</a> a)</tt>
--   
--   <pre>
--   &gt;&gt;&gt; getLast (Last (Just "hello") &lt;&gt; Last Nothing &lt;&gt; Last (Just "world"))
--   Just "world"
--   </pre>
newtype Last a
Last :: Maybe a -> Last a
[getLast] :: Last a -> Maybe a

-- | The dual of a <a>Monoid</a>, obtained by swapping the arguments of
--   <a>mappend</a>.
--   
--   <pre>
--   &gt;&gt;&gt; getDual (mappend (Dual "Hello") (Dual "World"))
--   "WorldHello"
--   </pre>
newtype Dual a
Dual :: a -> Dual a
[getDual] :: Dual a -> a

-- | The monoid of endomorphisms under composition.
--   
--   <pre>
--   &gt;&gt;&gt; let computation = Endo ("Hello, " ++) &lt;&gt; Endo (++ "!")
--   
--   &gt;&gt;&gt; appEndo computation "Haskell"
--   "Hello, Haskell!"
--   </pre>
newtype Endo a
Endo :: a -> a -> Endo a
[appEndo] :: Endo a -> a -> a

-- | Boolean monoid under conjunction (<a>&amp;&amp;</a>).
--   
--   <pre>
--   &gt;&gt;&gt; getAll (All True &lt;&gt; mempty &lt;&gt; All False)
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; getAll (mconcat (map (\x -&gt; All (even x)) [2,4,6,7,8]))
--   False
--   </pre>
newtype All
All :: Bool -> All
[getAll] :: All -> Bool

-- | Boolean monoid under disjunction (<a>||</a>).
--   
--   <pre>
--   &gt;&gt;&gt; getAny (Any True &lt;&gt; mempty &lt;&gt; Any False)
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; getAny (mconcat (map (\x -&gt; Any (even x)) [2,4,6,7,8]))
--   True
--   </pre>
newtype Any
Any :: Bool -> Any
[getAny] :: Any -> Bool

-- | Monoid under addition.
--   
--   <pre>
--   &gt;&gt;&gt; getSum (Sum 1 &lt;&gt; Sum 2 &lt;&gt; mempty)
--   3
--   </pre>
newtype Sum a
Sum :: a -> Sum a
[getSum] :: Sum a -> a

-- | Monoid under multiplication.
--   
--   <pre>
--   &gt;&gt;&gt; getProduct (Product 3 &lt;&gt; Product 4 &lt;&gt; mempty)
--   12
--   </pre>
newtype Product a
Product :: a -> Product a
[getProduct] :: Product a -> a

-- | Monoid under <a>&lt;|&gt;</a>.
newtype Alt (f :: k -> *) (a :: k) :: forall k. () => k -> * -> k -> *
Alt :: f a -> Alt
[getAlt] :: Alt -> f a
union :: Enumerate a -> Enumerate a -> Enumerate a
cartesian :: () => Enumerate a -> Enumerate b -> Enumerate (a, b)

-- | The definition of <tt>pure</tt> for the applicative instance.
singleton :: a -> Enumerate a

-- | Increases the cost/size of all values in the given set.
pay :: Sized f => f a -> f a
instance GHC.Show.Show a => GHC.Show.Show (Test.Feat.Enumerate.RevList a)
instance GHC.Base.Functor Test.Feat.Enumerate.Enumerate
instance GHC.Base.Applicative Test.Feat.Enumerate.Enumerate
instance GHC.Base.Alternative Test.Feat.Enumerate.Enumerate
instance Control.Sized.Sized Test.Feat.Enumerate.Enumerate
instance GHC.Base.Semigroup (Test.Feat.Enumerate.Enumerate a)
instance GHC.Base.Monoid (Test.Feat.Enumerate.Enumerate a)
instance GHC.Base.Functor Test.Feat.Enumerate.RevList
instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Test.Feat.Enumerate.RevList a)
instance (GHC.Base.Monoid a, GHC.Base.Semigroup a) => GHC.Base.Monoid (Test.Feat.Enumerate.RevList a)


-- | Functions for accessing the values of enumerations including
--   compatibility with the property based testing framework QuickCheck
module Test.Feat.Access

-- | Memoised enumeration. Note that all cardinalities are kept in memory
--   until your program terminates.
optimal :: Enumerable a => Enumerate a

-- | Index into an enumeration. Mainly used for party tricks (give it a
--   really large number), since usually you want to distinguish values by
--   size.
index :: Enumerable a => Integer -> a

-- | A more fine grained version of index that takes a size and an index
--   into the values of that size. <tt>select p i</tt> is only defined for
--   <tt>i</tt> within bounds (meaning <tt>i &lt; fst (values !! p)</tt>).
select :: Enumerable a => Int -> Index -> a

-- | All values of the enumeration by increasing cost (which is the number
--   of constructors for most types). Also contains the length of each
--   list.
values :: Enumerable a => [(Integer, [a])]

-- | Compatibility with QuickCheck. Distribution is uniform generator over
--   values bounded by the given size. Typical use: <tt>sized uniform</tt>.
uniform :: Enumerable a => Int -> Gen a

-- | Enumerates every nth value of the enumeration from a given starting
--   index. As a special case <tt>striped 0 1</tt> gives all values (starts
--   at index 0 and takes steps of 1).
--   
--   Useful for running enumerations in parallel since e.g. <tt>striped 0
--   2</tt> is disjoint from <tt>striped 1 2</tt> and the union of the two
--   cover all values.
skipping :: Enumerate a -> Index -> Integer -> Enumerate a

-- | A version of values with a limited number of values in each inner
--   list. If the list corresponds to a Part which is larger than the bound
--   it evenly distributes the values across the enumeration of the Part.
bounded :: Enumerate a -> Integer -> Enumerate a

-- | Remove all sizes exept those in the given inclusive (low,high) range
sizeRange :: Enumerate a -> (Int, Int) -> Enumerate a

-- | Non class version of <a>index</a>.
indexWith :: Enumerate a -> Integer -> a

-- | Non class version of <a>select</a>
selectWith :: Enumerate a -> Int -> Index -> a

-- | Non class version of <a>values</a>.
valuesWith :: Enumerate a -> [(Integer, [a])]

-- | Non class version of <a>uniform</a>.
uniformWith :: Enumerate a -> Int -> Gen a


-- | A simple testing driver for testing properties using FEAT. Contains
--   three drivers with different levels of flexibility of configuration.
--   
--   Ironically, this code is mostly untested at the moment.
module Test.Feat.Driver

-- | Test with default options (<a>defOptions</a>). Returns a list of
--   counterexamples
test :: Enumerable a => (a -> Bool) -> IO [a]

-- | Test with basic options. Returns a list of counterexamples.
testOptions :: Enumerable a => Options -> (a -> Bool) -> IO [a]

-- | Basic options for executing a test. Unlike <a>FlexibleOptions</a> this
--   type has Show/Read instances.
data Options
Options :: Maybe Int -> Maybe (Int, Int) -> Maybe Int -> Bool -> Maybe (Index, Integer) -> Maybe Integer -> Options
[oTimeoutSec] :: Options -> Maybe Int

-- | (first size, last size)
[oSizeFromTo] :: Options -> Maybe (Int, Int)

-- | Maximum number of counterexamples
[oMaxCounter] :: Options -> Maybe Int
[oSilent] :: Options -> Bool

-- | (start-index, steps to skip)
[oSkipping] :: Options -> Maybe (Index, Integer)

-- | Maximum number of tests per size
[oBounded] :: Options -> Maybe Integer

-- | 60 seconds timeout, maximum size of 100, bound of 100000 tests per
--   size
defOptions :: Options

-- | The most flexible test driver, can be configured to behave in almost
--   any way.
testFlex :: FlexibleOptions a -> (a -> Bool) -> IO (Result, [a])
data Result

-- | Reached max size
Exhausted :: Result

-- | Reached max number of counterexamples
Quota :: Result
TimedOut :: Result
Other :: Result

-- | Much more flexible options for configuring every part of the test
--   execution. <tt>a</tt> is the parameter type of the property.
type FlexibleOptions a = IO (FlexOptions a)

-- | FlexOptions
data FlexOptions a
FlexOptions :: IO Bool -> IO (Result, [a]) -> a -> IO Bool -> String -> IO () -> Enumerate a -> Enumerate a -> Enumerate a -> FlexOptions a

-- | The whole execution of the test is sent through this function.
[fIO] :: FlexOptions a -> IO Bool -> IO (Result, [a])

-- | Applied to each found counterexample, return False to stop testing
[fReport] :: FlexOptions a -> a -> IO Bool

-- | Print text
[fOutput] :: FlexOptions a -> String -> IO ()

-- | Applied to the enumeration before running
[fProcess] :: FlexOptions a -> Enumerate a -> Enumerate a

-- | The base enumeration to use, before applying <tt>fProcess</tt>.
[fEnum] :: FlexOptions a -> Enumerate a
defFlex :: Enumerable a => FlexibleOptions a
toFlex :: Enumerable a => Options -> FlexibleOptions a
toFlexWith :: Enumerate a -> Options -> FlexibleOptions a
instance GHC.Show.Show Test.Feat.Driver.Result
instance GHC.Read.Read Test.Feat.Driver.Options
instance GHC.Show.Show Test.Feat.Driver.Options


-- | This module contains a (hopefully) manageable subset of the
--   functionality of Feat. The rest resides only in the Test.Feat.*
--   modules.
module Test.Feat

-- | Test with default options (<a>defOptions</a>). Returns a list of
--   counterexamples
test :: Enumerable a => (a -> Bool) -> IO [a]

-- | Test with basic options. Returns a list of counterexamples.
testOptions :: Enumerable a => Options -> (a -> Bool) -> IO [a]

-- | Basic options for executing a test. Unlike <a>FlexibleOptions</a> this
--   type has Show/Read instances.
data Options
Options :: Maybe Int -> Maybe (Int, Int) -> Maybe Int -> Bool -> Maybe (Index, Integer) -> Maybe Integer -> Options
[oTimeoutSec] :: Options -> Maybe Int

-- | (first size, last size)
[oSizeFromTo] :: Options -> Maybe (Int, Int)

-- | Maximum number of counterexamples
[oMaxCounter] :: Options -> Maybe Int
[oSilent] :: Options -> Bool

-- | (start-index, steps to skip)
[oSkipping] :: Options -> Maybe (Index, Integer)

-- | Maximum number of tests per size
[oBounded] :: Options -> Maybe Integer

-- | 60 seconds timeout, maximum size of 100, bound of 100000 tests per
--   size
defOptions :: Options

-- | A functional enumeration of type <tt>t</tt> is a partition of
--   <tt>t</tt> into finite numbered sets called Parts. Each parts contains
--   values of a certain cost (typically the size of the value).
data Enumerate a
class Typeable a => Enumerable a
enumerate :: (Enumerable a, Typeable f, Sized f) => Shared f a

-- | Builds an enumeration of a data type from a list of constructors (see
--   c0-c7)
datatype :: (Typeable a, Sized f, Typeable f) => [Shareable f a] -> Shared f a

-- | Takes a constructor with arity 0 (a pure value)
c0 :: Sized f => a -> Shareable f a

-- | Takes a constructor of arity 1
c1 :: (Enumerable a, Sized f, Typeable f) => a -> x -> Shareable f x
c2 :: (Enumerable a, Enumerable b, Sized f, Typeable f) => a -> b -> x -> Shareable f x
c3 :: (Enumerable a, Enumerable b, Enumerable c, Sized f, Typeable f) => a -> b -> c -> x -> Shareable f x
c4 :: (Enumerable a, Enumerable b, Enumerable c, Enumerable d, Sized f, Typeable f) => a -> b -> c -> d -> x -> Shareable f x
c5 :: (Enumerable a, Enumerable b, Enumerable c, Enumerable d, Enumerable e, Sized f, Typeable f) => a -> b -> c -> d -> e -> x -> Shareable f x
c6 :: (Enumerable a, Enumerable b, Enumerable c, Enumerable d, Enumerable e, Enumerable g, Sized f, Typeable f) => a -> b -> c -> d -> e -> g -> x -> Shareable f x
c7 :: (Enumerable a, Enumerable b, Enumerable c, Enumerable d, Enumerable e, Enumerable g, Enumerable h, Sized f, Typeable f) => a -> b -> c -> d -> e -> g -> h -> x -> Shareable f x
deriveEnumerable :: Name -> Q [Dec]

-- | Memoised enumeration. Note that all cardinalities are kept in memory
--   until your program terminates.
optimal :: Enumerable a => Enumerate a

-- | Index into an enumeration. Mainly used for party tricks (give it a
--   really large number), since usually you want to distinguish values by
--   size.
index :: Enumerable a => Integer -> a

-- | A more fine grained version of index that takes a size and an index
--   into the values of that size. <tt>select p i</tt> is only defined for
--   <tt>i</tt> within bounds (meaning <tt>i &lt; fst (values !! p)</tt>).
select :: Enumerable a => Int -> Index -> a

-- | All values of the enumeration by increasing cost (which is the number
--   of constructors for most types). Also contains the length of each
--   list.
values :: Enumerable a => [(Integer, [a])]

-- | Compatibility with QuickCheck. Distribution is uniform generator over
--   values bounded by the given size. Typical use: <tt>sized uniform</tt>.
uniform :: Enumerable a => Int -> Gen a


-- | Modifiers for types, i.e. newtype wrappers where the values satisfy
--   some constraint (non-empty, positive etc.). Suggestions on useful
--   types are appreciated.
--   
--   To apply the modifiers types you can use the record label. For
--   instance:
--   
--   <pre>
--   data C a = C [a] [a] deriving <tt>Typeable</tt>
--   instance <tt>Enumerable</tt> a =&gt; <tt>Enumerable</tt> (C a) where
--      <tt>enumerate</tt> = <tt>c2</tt> $
--        \xs ys -&gt; C (<a>nonEmpty</a> xs) (<a>nonEmpty</a> ys)
--   </pre>
--   
--   Alternatively you can put everything in pattern postition:
--   
--   <pre>
--   instance <tt>Enumerable</tt> a =&gt; <tt>Enumerable</tt> (C a) where
--      <tt>enumerate</tt> = <tt>unary</tt> $ <tt>funcurry</tt> $
--        \(<tt>Free</tt> (<a>NonEmpty</a> xs,<a>NonEmpty</a> ys)) -&gt; C xs ys)
--   </pre>
--   
--   The first approach has the advantage of being usable with a point free
--   style: <tt> \xs -&gt; C (<a>nonEmpty</a> xs) . <a>nonEmpty</a> </tt>.
module Test.Feat.Modifiers
