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


-- | refining property sets for testing Haskell programs
--   
--   FitSpec provides automated assistance in the task of refining test
--   properties for Haskell functions.
--   
--   FitSpec tests mutant variations of functions under test against a
--   given property set, recording any surviving mutants that pass all
--   tests. FitSpec then reports:
--   
--   <ul>
--   <li>surviving mutants: indicating incompleteness of properties,
--   prompting the user to amend a property or to add a new one;</li>
--   <li>conjectures: indicating redundancy in the property set, prompting
--   the user to remove properties so to reduce the cost of testing.</li>
--   </ul>
@package fitspec
@version 0.4.4


-- | Enumeration of function mutations
module Test.FitSpec.Mutable

-- | This typeclass is similar to <a>Listable</a>.
--   
--   A type is <a>Mutable</a> when there exists a function that is able to
--   list mutations of a value. Ideally: list all possible values without
--   repetitions.
--   
--   Instances are usually defined by a <a>mutiers</a> function that given
--   a value, returns tiers of mutants of that value: the first tier
--   contains the equivalent mutant, of size 0, the second tier contains
--   mutants of size 1, the third tier contains mutants of size 2, and so
--   on.
--   
--   The equivalent mutant is the actual function without mutations.
--   
--   The size of a mutant is given by the sum of: the number of mutated
--   points (relations) and the sizes of mutated arguments and results.
--   
--   To get only inequivalent mutants, just take the <a>tail</a> of either
--   <a>mutants</a> or <a>mutiers</a>:
--   
--   <pre>
--   tail mutants
--   </pre>
--   
--   <pre>
--   tail mutiers
--   </pre>
--   
--   Given that the underlying <a>Listable</a> enumeration has no
--   repetitions, parametric instances defined in this file will have no
--   repeated mutants.
class Mutable a
mutiers :: Mutable a => a -> [[a]]
mutants :: Mutable a => a -> [a]

-- | Implementation of <a>mutiers</a> for non-functional data types. Use
--   this to create instances for user-defined data types, e.g.:
--   
--   <pre>
--   instance MyData
--     where mutiers = mutiersEq
--   </pre>
--   
--   and for parametric datatypes:
--   
--   <pre>
--   instance (Eq a, Eq b) =&gt; MyDt a b
--     where mutiers = mutiersEq
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   mutiersEq True = [[True], [False]]
--   mutiersEq 2   = [[2], [0], [1], [], [3], [4], [5], [6], [7], [8], [9], ...]
--   mutiersEq [1] = [[[1]], [[]], [[0]], [[0,0]], [[0,0,0],[0,1],[1,0],[-1]], ...]
--   </pre>
mutiersEq :: (Listable a, Eq a) => a -> [[a]]
instance Test.FitSpec.Mutable.Mutable ()
instance Test.FitSpec.Mutable.Mutable GHC.Types.Int
instance Test.FitSpec.Mutable.Mutable GHC.Integer.Type.Integer
instance Test.FitSpec.Mutable.Mutable GHC.Types.Char
instance Test.FitSpec.Mutable.Mutable GHC.Types.Bool
instance (GHC.Classes.Eq a, Test.LeanCheck.Core.Listable a) => Test.FitSpec.Mutable.Mutable [a]
instance (GHC.Classes.Eq a, Test.LeanCheck.Core.Listable a) => Test.FitSpec.Mutable.Mutable (GHC.Base.Maybe a)
instance (GHC.Classes.Eq a, Test.LeanCheck.Core.Listable a, GHC.Classes.Eq b, Test.LeanCheck.Core.Listable b) => Test.FitSpec.Mutable.Mutable (Data.Either.Either a b)
instance (GHC.Classes.Eq a, Test.LeanCheck.Core.Listable a, GHC.Real.Integral a) => Test.FitSpec.Mutable.Mutable (GHC.Real.Ratio a)
instance Test.FitSpec.Mutable.Mutable GHC.Types.Float
instance Test.FitSpec.Mutable.Mutable GHC.Types.Double
instance Test.FitSpec.Mutable.Mutable GHC.Types.Ordering
instance Test.FitSpec.Mutable.Mutable GHC.Types.Word
instance (GHC.Classes.Eq a, Test.LeanCheck.Core.Listable a, Test.FitSpec.Mutable.Mutable b) => Test.FitSpec.Mutable.Mutable (a -> b)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b) => Test.FitSpec.Mutable.Mutable (a, b)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c) => Test.FitSpec.Mutable.Mutable (a, b, c)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c, Test.FitSpec.Mutable.Mutable d) => Test.FitSpec.Mutable.Mutable (a, b, c, d)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c, Test.FitSpec.Mutable.Mutable d, Test.FitSpec.Mutable.Mutable e) => Test.FitSpec.Mutable.Mutable (a, b, c, d, e)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c, Test.FitSpec.Mutable.Mutable d, Test.FitSpec.Mutable.Mutable e, Test.FitSpec.Mutable.Mutable f) => Test.FitSpec.Mutable.Mutable (a, b, c, d, e, f)


-- | Mutable instances: septuples up to 12-tuples
--   
--   This is partly a Hack that allows those instances to be hidden from
--   Haddock. Otherwise Haddock documentation will look very ugly. It also
--   makes <a>Test.FitSpec.ShowMutable</a> more readable.
--   
--   This module is already exported by <a>Test.FitSpec</a>, so it is not
--   needed to import this explictly.
module Test.FitSpec.Mutable.Tuples
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c, Test.FitSpec.Mutable.Mutable d, Test.FitSpec.Mutable.Mutable e, Test.FitSpec.Mutable.Mutable f, Test.FitSpec.Mutable.Mutable g) => Test.FitSpec.Mutable.Mutable (a, b, c, d, e, f, g)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c, Test.FitSpec.Mutable.Mutable d, Test.FitSpec.Mutable.Mutable e, Test.FitSpec.Mutable.Mutable f, Test.FitSpec.Mutable.Mutable g, Test.FitSpec.Mutable.Mutable h) => Test.FitSpec.Mutable.Mutable (a, b, c, d, e, f, g, h)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c, Test.FitSpec.Mutable.Mutable d, Test.FitSpec.Mutable.Mutable e, Test.FitSpec.Mutable.Mutable f, Test.FitSpec.Mutable.Mutable g, Test.FitSpec.Mutable.Mutable h, Test.FitSpec.Mutable.Mutable i) => Test.FitSpec.Mutable.Mutable (a, b, c, d, e, f, g, h, i)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c, Test.FitSpec.Mutable.Mutable d, Test.FitSpec.Mutable.Mutable e, Test.FitSpec.Mutable.Mutable f, Test.FitSpec.Mutable.Mutable g, Test.FitSpec.Mutable.Mutable h, Test.FitSpec.Mutable.Mutable i, Test.FitSpec.Mutable.Mutable j) => Test.FitSpec.Mutable.Mutable (a, b, c, d, e, f, g, h, i, j)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c, Test.FitSpec.Mutable.Mutable d, Test.FitSpec.Mutable.Mutable e, Test.FitSpec.Mutable.Mutable f, Test.FitSpec.Mutable.Mutable g, Test.FitSpec.Mutable.Mutable h, Test.FitSpec.Mutable.Mutable i, Test.FitSpec.Mutable.Mutable j, Test.FitSpec.Mutable.Mutable k) => Test.FitSpec.Mutable.Mutable (a, b, c, d, e, f, g, h, i, j, k)
instance (Test.FitSpec.Mutable.Mutable a, Test.FitSpec.Mutable.Mutable b, Test.FitSpec.Mutable.Mutable c, Test.FitSpec.Mutable.Mutable d, Test.FitSpec.Mutable.Mutable e, Test.FitSpec.Mutable.Mutable f, Test.FitSpec.Mutable.Mutable g, Test.FitSpec.Mutable.Mutable h, Test.FitSpec.Mutable.Mutable i, Test.FitSpec.Mutable.Mutable j, Test.FitSpec.Mutable.Mutable k, Test.FitSpec.Mutable.Mutable l) => Test.FitSpec.Mutable.Mutable (a, b, c, d, e, f, g, h, i, j, k, l)


-- | A very simple pretty printing library used to generate <a>FitSpec</a>
--   reports.
module Test.FitSpec.PrettyPrint

-- | Appends two Strings side by side, line by line
--   
--   <pre>
--   beside ["asdf\nqw\n","zxvc\nas"] ==
--    "asdfzxvc\n\
--    \qw  as\n"
--   </pre>
beside :: String -> String -> String

-- | Append two Strings on top of each other, adding line breaks *when
--   needed*.
above :: String -> String -> String

-- | Show elements of a list as a tuple. If there are multiple lines in any
--   of the strings, tuple is printed multiline.
--   
--   <pre>
--   showTuple ["asdf\nqwer\n","zxvc\nasdf\n"] ==
--     "( asdf\n\
--     \  qwer\n\
--     \, zxvc\n\
--     \  asdf )\n"
--   </pre>
--   
--   <pre>
--   showTuple ["asdf","qwer"] == "(asdf,qwer)"
--   </pre>
showTuple :: [String] -> String

-- | Formats a table using a given separator.
--   
--   <pre>
--   table "  " [ ["asdf", "qwer",     "zxvc\nzxvc"]
--              , ["0",    "1",        "2"]
--              , ["123",  "456\n789", "3"] ] ==
--     "asdf  qwer  zxvc\n\
--     \            zxvc\n\
--     \0     1     2\n\
--     \123   456   3\n\
--     \      789\n\"
--   </pre>
table :: String -> [[String]] -> String

-- | Given a separator, format strings in columns
--   
--   <pre>
--   columns " | " ["asdf", "qw\nzxcv", "as\ndf"] ==
--     "asdf | qw   | as\n\
--     \     | zxcv | df\n"
--   </pre>
columns :: String -> [String] -> String
showQuantity :: Int -> String -> String
showEach :: Show a => String -> [a] -> String
headToUpper :: [Char] -> [Char]


-- | Exports a typeclass to show mutant variations.
module Test.FitSpec.ShowMutable

-- | Types that can have their mutation shown. Has only one function
--   <a>mutantS</a> that returns a simple AST (<a>MutantS</a>) representing
--   the mutant. A standard implementation of <a>mutantS</a> for <a>Eq</a>
--   types is given by <a>mutantSEq</a>.
class ShowMutable a
mutantS :: ShowMutable a => a -> a -> MutantS

-- | For a given type <tt>Type</tt> instance of <tt>Eq</tt> and
--   <tt>Show</tt>, define the <a>ShowMutable</a> instance as:
--   
--   <pre>
--   instance ShowMutable Type
--     where mutantS = mutantSEq
--   </pre>
mutantSEq :: (Eq a, Show a) => a -> a -> MutantS

-- | Show a Mutant as a tuple of lambdas.
--   
--   <pre>
--   &gt; putStrLn $ showMutantAsTuple ["p &amp;&amp; q","not p"] ((&amp;&amp;),not) ((||),id)
--   ( \p q -&gt; case (p,q) of
--              (False,False) -&gt; True
--              _ -&gt; p &amp;&amp; q
--   , \p -&gt; case p of
--             False -&gt; False
--             True -&gt; True
--             _ -&gt; not p )
--   </pre>
--   
--   Can be easily copy pasted into an interactive session for
--   manipulation. On GHCi, use <tt>:{</tt> and <tt>:}</tt> to allow
--   multi-line expressions and definitions.
showMutantAsTuple :: ShowMutable a => [String] -> a -> a -> String

-- | Show a Mutant as a tuple of nested lambdas. Very similar to
--   <a>showMutantAsTuple</a>, but the underlying data structure is not
--   flatten: so the output is as close as possible to the underlying
--   representation.
showMutantNested :: ShowMutable a => [String] -> a -> a -> String

-- | Show a Mutant as a new complete top-level definition, with a prime
--   appended to the name of the mutant.
--   
--   <pre>
--   &gt; putStrLn $ showMutantDefinition ["p &amp;&amp; q","not p"] ((&amp;&amp;),not) ((==),id)
--   False &amp;&amp;- False = True
--   p     &amp;&amp;- q     = p &amp;&amp; q
--   not' False = False
--   not' True  = True
--   not' p     = not p
--   </pre>
showMutantDefinition :: ShowMutable a => [String] -> a -> a -> String

-- | Show a Mutant as the list of bindings that differ from the original
--   function(s).
--   
--   <pre>
--   &gt; putStrLn $ showMutantBindings ["p &amp;&amp; q","not p"] ((&amp;&amp;),not) ((==),id)
--   False &amp;&amp; False = True
--   not False = False
--   not True  = True
--   </pre>
--   
--   Can possibly be copied into the source of the original function for
--   manipulation.
showMutantBindings :: ShowMutable a => [String] -> a -> a -> String

-- | (Show) Structure of a mutant. This format is intended for processing
--   then pretty-printing.
data MutantS
mutantSTuple :: [MutantS] -> MutantS
instance GHC.Show.Show Test.FitSpec.ShowMutable.MutantS
instance Test.FitSpec.ShowMutable.ShowMutable ()
instance Test.FitSpec.ShowMutable.ShowMutable GHC.Types.Int
instance Test.FitSpec.ShowMutable.ShowMutable GHC.Integer.Type.Integer
instance Test.FitSpec.ShowMutable.ShowMutable GHC.Types.Char
instance Test.FitSpec.ShowMutable.ShowMutable GHC.Types.Bool
instance (GHC.Classes.Eq a, GHC.Show.Show a) => Test.FitSpec.ShowMutable.ShowMutable [a]
instance (GHC.Classes.Eq a, GHC.Show.Show a) => Test.FitSpec.ShowMutable.ShowMutable (GHC.Base.Maybe a)
instance (GHC.Classes.Eq a, GHC.Show.Show a, GHC.Classes.Eq b, GHC.Show.Show b) => Test.FitSpec.ShowMutable.ShowMutable (Data.Either.Either a b)
instance (GHC.Classes.Eq a, GHC.Show.Show a, GHC.Real.Integral a) => Test.FitSpec.ShowMutable.ShowMutable (GHC.Real.Ratio a)
instance Test.FitSpec.ShowMutable.ShowMutable GHC.Types.Float
instance Test.FitSpec.ShowMutable.ShowMutable GHC.Types.Double
instance Test.FitSpec.ShowMutable.ShowMutable GHC.Types.Ordering
instance Test.FitSpec.ShowMutable.ShowMutable GHC.Types.Word
instance (Test.LeanCheck.Core.Listable a, GHC.Show.Show a, Test.FitSpec.ShowMutable.ShowMutable b) => Test.FitSpec.ShowMutable.ShowMutable (a -> b)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b) => Test.FitSpec.ShowMutable.ShowMutable (a, b)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c, Test.FitSpec.ShowMutable.ShowMutable d) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c, d)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c, Test.FitSpec.ShowMutable.ShowMutable d, Test.FitSpec.ShowMutable.ShowMutable e) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c, d, e)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c, Test.FitSpec.ShowMutable.ShowMutable d, Test.FitSpec.ShowMutable.ShowMutable e, Test.FitSpec.ShowMutable.ShowMutable f) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c, d, e, f)


-- | Experimental module for deriving <a>Mutable</a> and <a>ShowMutable</a>
--   instances
--   
--   Needs GHC and Template Haskell (tested on GHC 7.4, 7.6, 7.8, 7.10 and
--   8.0)
--   
--   Despite <a>Mutable</a> instances being actually very simple to write
--   manually, this module can be used to derive those instances
--   automatically. However, it will not work on all cases: when that
--   happens, you should write your instances manually.
--   
--   If FitSpec does not compile under later GHCs, this module is probably
--   the culprit.
module Test.FitSpec.Derive

-- | Derives <a>Mutable</a>, <a>ShowMutable</a> and (optionally)
--   <a>Listable</a> instances 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>
--   deriveMutable ''Stack
--   </pre>
--   
--   will automatically derive the following <a>Listable</a>,
--   <a>Mutable</a> and <a>ShowMutable</a> instances:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Stack a) where
--     tiers = cons2 Stack \/ cons0 Empty
--   
--   instance (Eq a, Listable a) =&gt; Mutable a
--     where mutiers = mutiersEq
--   
--   instance (Eq a, Show a) =&gt; ShowMutable a
--     where mutantS = mutantSEq
--   </pre>
--   
--   If a <a>Listable</a> instance already exists, it is not derived. (cf.:
--   <a>deriveListable</a>)
--   
--   Needs the <tt>TemplateHaskell</tt> extension.
deriveMutable :: Name -> DecsQ

-- | Derives a Mutable instance for a given type <a>Name</a> using a given
--   context for all type variables.
deriveMutableE :: [Name] -> Name -> DecsQ
deriveMutableCascading :: Name -> DecsQ
deriveMutableCascadingE :: [Name] -> Name -> DecsQ


-- | ShowMutable instances: septuples up to 12-tuples
--   
--   This is partly a Hack that allows those instances to be hidden from
--   Haddock. Otherwise Haddock documentation will look very ugly. It also
--   makes <a>Test.FitSpec.ShowMutable</a> more readable.
module Test.FitSpec.ShowMutable.Tuples
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c, Test.FitSpec.ShowMutable.ShowMutable d, Test.FitSpec.ShowMutable.ShowMutable e, Test.FitSpec.ShowMutable.ShowMutable f, Test.FitSpec.ShowMutable.ShowMutable g) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c, d, e, f, g)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c, Test.FitSpec.ShowMutable.ShowMutable d, Test.FitSpec.ShowMutable.ShowMutable e, Test.FitSpec.ShowMutable.ShowMutable f, Test.FitSpec.ShowMutable.ShowMutable g, Test.FitSpec.ShowMutable.ShowMutable h) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c, d, e, f, g, h)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c, Test.FitSpec.ShowMutable.ShowMutable d, Test.FitSpec.ShowMutable.ShowMutable e, Test.FitSpec.ShowMutable.ShowMutable f, Test.FitSpec.ShowMutable.ShowMutable g, Test.FitSpec.ShowMutable.ShowMutable h, Test.FitSpec.ShowMutable.ShowMutable i) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c, d, e, f, g, h, i)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c, Test.FitSpec.ShowMutable.ShowMutable d, Test.FitSpec.ShowMutable.ShowMutable e, Test.FitSpec.ShowMutable.ShowMutable f, Test.FitSpec.ShowMutable.ShowMutable g, Test.FitSpec.ShowMutable.ShowMutable h, Test.FitSpec.ShowMutable.ShowMutable i, Test.FitSpec.ShowMutable.ShowMutable j) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c, d, e, f, h, g, i, j)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c, Test.FitSpec.ShowMutable.ShowMutable d, Test.FitSpec.ShowMutable.ShowMutable e, Test.FitSpec.ShowMutable.ShowMutable f, Test.FitSpec.ShowMutable.ShowMutable g, Test.FitSpec.ShowMutable.ShowMutable h, Test.FitSpec.ShowMutable.ShowMutable i, Test.FitSpec.ShowMutable.ShowMutable j, Test.FitSpec.ShowMutable.ShowMutable k) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c, d, e, f, g, h, i, j, k)
instance (Test.FitSpec.ShowMutable.ShowMutable a, Test.FitSpec.ShowMutable.ShowMutable b, Test.FitSpec.ShowMutable.ShowMutable c, Test.FitSpec.ShowMutable.ShowMutable d, Test.FitSpec.ShowMutable.ShowMutable e, Test.FitSpec.ShowMutable.ShowMutable f, Test.FitSpec.ShowMutable.ShowMutable g, Test.FitSpec.ShowMutable.ShowMutable h, Test.FitSpec.ShowMutable.ShowMutable i, Test.FitSpec.ShowMutable.ShowMutable j, Test.FitSpec.ShowMutable.ShowMutable k, Test.FitSpec.ShowMutable.ShowMutable l) => Test.FitSpec.ShowMutable.ShowMutable (a, b, c, d, e, f, g, h, i, j, k, l)


-- | FitSpec's Test Types: <a>Nat</a>, <a>Int2</a>, <a>Int3</a>,
--   <a>Int4</a>, <a>UInt2</a>, <a>UInt3</a>, <a>UInt4</a>.
--   
--   This module re-exports <a>Test.LeanCheck.Utils.Types</a> module and
--   defines <a>Mutable</a> and <a>ShowMutable</a> instances for the types
--   defined there.
module Test.FitSpec.TestTypes
instance Test.FitSpec.Mutable.Mutable Test.LeanCheck.Utils.Types.Nat
instance Test.FitSpec.Mutable.Mutable Test.LeanCheck.Utils.Types.Int1
instance Test.FitSpec.Mutable.Mutable Test.LeanCheck.Utils.Types.Int2
instance Test.FitSpec.Mutable.Mutable Test.LeanCheck.Utils.Types.Int3
instance Test.FitSpec.Mutable.Mutable Test.LeanCheck.Utils.Types.Int4
instance Test.FitSpec.Mutable.Mutable Test.LeanCheck.Utils.Types.Word1
instance Test.FitSpec.Mutable.Mutable Test.LeanCheck.Utils.Types.Word2
instance Test.FitSpec.Mutable.Mutable Test.LeanCheck.Utils.Types.Word3
instance Test.FitSpec.Mutable.Mutable Test.LeanCheck.Utils.Types.Word4
instance Test.FitSpec.ShowMutable.ShowMutable Test.LeanCheck.Utils.Types.Nat
instance Test.FitSpec.ShowMutable.ShowMutable Test.LeanCheck.Utils.Types.Int1
instance Test.FitSpec.ShowMutable.ShowMutable Test.LeanCheck.Utils.Types.Int2
instance Test.FitSpec.ShowMutable.ShowMutable Test.LeanCheck.Utils.Types.Int3
instance Test.FitSpec.ShowMutable.ShowMutable Test.LeanCheck.Utils.Types.Int4
instance Test.FitSpec.ShowMutable.ShowMutable Test.LeanCheck.Utils.Types.Word1
instance Test.FitSpec.ShowMutable.ShowMutable Test.LeanCheck.Utils.Types.Word2
instance Test.FitSpec.ShowMutable.ShowMutable Test.LeanCheck.Utils.Types.Word3
instance Test.FitSpec.ShowMutable.ShowMutable Test.LeanCheck.Utils.Types.Word4


-- | General purpose utility functions for FitSpec
module Test.FitSpec.Utils

-- | Compose composed with compose operator.
--   
--   <pre>
--   (f ... g) x y === f (g x y)
--   </pre>
(...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d
count :: (a -> Bool) -> [a] -> Int

-- | <a>compositions</a> <tt>bs</tt> returns all compositions formed by
--   taking values of <tt>bs</tt>
compositions :: [Bool] -> [Bool]

-- | <a>subsets</a> <tt>xs</tt> returns the list of sublists formed by
--   taking values of <tt>xs</tt>
subsets :: [a] -> [[a]]

-- | Check if all elements of a list is contained in another list
contained :: Eq a => [a] -> [a] -> Bool
contains :: Eq a => [a] -> [a] -> Bool

-- | <a>filterU</a> filter greater-later elements in a list according to a
--   partial ordering relation.
--   
--   <pre>
--   filterU (notContained) [[1],[2],[1,2,3],[3,4,5]] == [[1],[2],[3,4,5]]
--   </pre>
filterU :: (a -> a -> Bool) -> [a] -> [a]
sortAndGroupOn :: Ord b => (a -> b) -> [a] -> [[a]]
sortAndGroupFstBySnd :: Ord b => [(a, b)] -> [([a], b)]
sortGroupAndCollapse :: Ord b => (a -> b) -> (a -> c) -> (b -> [c] -> d) -> [a] -> [d]

-- | Takes values from a list while the values increase. If the original
--   list is non-empty, the returning list will also be non-empty
takeWhileIncreasing :: (a -> a -> Ordering) -> [a] -> [a]
takeWhileIncreasingOn :: Ord b => (a -> b) -> [a] -> [a]

-- | <tt>lastTimeout s xs</tt> will take the last value of <tt>xs</tt> it
--   is able evaluate before <tt>s</tt> seconds elapse.
lastTimeout :: Int -> [a] -> IO a
sortOn :: Ord b => (a -> b) -> [a] -> [a]
(***) :: (a -> b) -> (c -> d) -> (a, c) -> (b, d)


-- | FitSpec: refining property-sets for functional testing
--   
--   This is the main engine, besides <a>Test.FitSpec.Mutable</a>.
module Test.FitSpec.Engine

-- | Given a <a>Testable</a> type (as defined by <a>Test.LeanCheck</a>),
--   returns a <a>Property</a>.
--   
--   This function should be used on every property to create a property
--   list to be passed to <tt>report</tt>, <tt>reportWith</tt>,
--   <tt>mainDefault</tt> or <tt>mainWith</tt>.
--   
--   <pre>
--   property $ \x y -&gt; x + y &lt; y + (x::Int)
--   </pre>
property :: Testable a => a -> Property

-- | An encoded representation of a property suitable for use by FitSpec.
--   
--   Each list of strings is a printable representation of one possible
--   choice of argument values for the property. Each boolean indicate
--   whether the property holds for this choice.
type Property = [([String], Bool)]

-- | Return minimality and completeness results. See <tt>report</tt>.
getResults :: (Mutable a) => a -> (a -> [Property]) -> Int -> Int -> Results a
getResultsExtra :: (Mutable a) => [a] -> a -> (a -> [Property]) -> Int -> Int -> Results a
getResultsExtraTimeout :: (Mutable a) => Int -> [a] -> a -> (a -> [Property]) -> Int -> Int -> IO (Results a)

-- | A line of result for a single equivalence class of properties with the
--   exact same surviving mutants.
data Result a
Result :: [[Int]] -> [Int] -> [a] -> Maybe a -> Int -> Int -> Int -> Int -> Int -> Bool -> Result a

-- | property-sets in the equivalence class
[sets] :: Result a -> [[Int]]

-- | properties implied by this class
[implied] :: Result a -> [Int]

-- | list of surviving mutants
[survivors] :: Result a -> [a]

-- | smallest surviving mutant, if any
[smallestSurvivor] :: Result a -> Maybe a

-- | number of surviving mutants
[nSurvivors] :: Result a -> Int

-- | number of killed mutants
[nKilled] :: Result a -> Int

-- | total number of mutants generated and tested
[totalMutants] :: Result a -> Int

-- | percentage of killed mutants, 0-100
[score] :: Result a -> Int

-- | Requested number of tests (same for all rs.)
[maxTests] :: Result a -> Int

-- | mutants were exhausted
[mutantsExhausted] :: Result a -> Bool
type Results a = [Result a]
propertiesNTests :: Int -> [Property] -> [Int]
propertiesTestsExhausted :: Int -> [Property] -> [Bool]
propertiesToMap :: [Property] -> Int -> [Bool]
propertiesHold :: Int -> [Property] -> Bool
propertiesCE :: Int -> [Property] -> Maybe String
minimal :: Results a -> Bool
complete :: Results a -> Bool
reduceImplications :: [Result a] -> [Result a]
filterNonCanon :: [Result a] -> [Result a]
data Conjecture
Conjecture :: Bool -> Bool -> [Int] -> [Int] -> Int -> Int -> Int -> Conjecture
[isEq] :: Conjecture -> Bool
[isIm] :: Conjecture -> Bool
[cleft] :: Conjecture -> [Int]
[cright] :: Conjecture -> [Int]
[cscore] :: Conjecture -> Int
[cnKilled] :: Conjecture -> Int
[cnSurvivors] :: Conjecture -> Int
conjectures :: [Result a] -> [Conjecture]
instance GHC.Show.Show Test.FitSpec.Engine.Conjecture


-- | Generate <a>FitSpec</a> reports.
module Test.FitSpec.Report

-- | Report results generated by FitSpec. Uses standard configuration (see
--   <a>args</a>). Needs a function to be mutated and a property map.
--   Example (specification of boolean negation):
--   
--   <pre>
--   properties not =
--     [ property $ \p -&gt; not (not p) == p
--     , property $ \p -&gt; not (not (not p)) == not p
--     ]
--   
--   main = report not properties
--   </pre>
report :: (Mutable a, ShowMutable a) => a -> (a -> [Property]) -> IO ()

-- | Same as <a>report</a> but can be configured via <a>Args</a>
--   (<a>args</a> or <a>fixargs</a>), e.g.:
--   
--   <pre>
--   reportWith args { timeout = 10 } fun properties
--   </pre>
reportWith :: (Mutable a, ShowMutable a) => Args -> a -> (a -> [Property]) -> IO ()

-- | Same as <a>reportWith</a>, but accepts a list of manually defined
--   (extra) mutants to be tested alongside those automatically generated.
reportWithExtra :: (Mutable a, ShowMutable a) => [a] -> Args -> a -> (a -> [Property]) -> IO ()

-- | Extra arguments / configuration for <a>reportWith</a>. See <a>args</a>
--   for default values.
data Args
Args :: Int -> Int -> Int -> [String] -> Bool -> ShowMutantAs -> Maybe Int -> [String] -> Args

-- | (starting) number of function mutations
[nMutants] :: Args -> Int

-- | (starting) number of test values (for each prop.)
[nTests] :: Args -> Int

-- | timeout in seconds, 0 for just <a>nTests</a> * <a>nMutants</a>
[timeout] :: Args -> Int

-- | names of functions: <tt>["foo x y","goo x y"]</tt>
[names] :: Args -> [String]

-- | whether to show detailed results
[verbose] :: Args -> Bool

-- | how to show mutants
[showMutantAs] :: Args -> ShowMutantAs

-- | number of surviving mutants to show
[rows] :: Args -> Maybe Int

-- | ignored argument (user defined meaning)
[extra] :: Args -> [String]

-- | Default arguments for <a>reportWith</a>:
--   
--   <ul>
--   <li><tt>nMutants = 500</tt>, start with 500 mutants</li>
--   <li><tt>nTests = 1000</tt>, start with 1000 test values</li>
--   <li><tt>timeout = 5</tt>, keep incresing the number of mutants until 5
--   seconds elapse</li>
--   <li><tt>names = []</tt>, default function call template:</li>
--   </ul>
--   
--   <pre>
--   ["f x y z", "g x y z", "h x y z", ...]
--   </pre>
args :: Args

-- | Non timed-out default arguments. Make conjectures based on a fixed
--   number of mutants and tests, e.g.:
--   
--   <pre>
--   reportWith (fixargs 100 200) f pmap
--   </pre>
--   
--   This is just a shorthand, see:
--   
--   <pre>
--   fixargs nm nt  =  args { nMutants = nm, nTests = nt, timeout = 0 }
--   </pre>
--   
--   <pre>
--   (fixargs nm nt) { nMutants = 500, nTests = 1000, timeout = 5 }  =  args
--   </pre>
fixargs :: Int -> Int -> Args

-- | An encoded representation of a property suitable for use by FitSpec.
--   
--   Each list of strings is a printable representation of one possible
--   choice of argument values for the property. Each boolean indicate
--   whether the property holds for this choice.
type Property = [([String], Bool)]

-- | How to show mutants. Use this to fill <a>showMutantAs</a>.
data ShowMutantAs
Tuple :: ShowMutantAs
NestedTuple :: ShowMutantAs
Definition :: ShowMutantAs
Bindings :: ShowMutantAs


-- | Exports "main" functions for FitSpec. They work exactly by
--   <a>report</a> and <a>reportWith</a> but can be customized by command
--   line arguments.
--   
--   <pre>
--   main = mainWith args { ... } functions properties
--   </pre>
module Test.FitSpec.Main

-- | Same as <a>reportWith</a>, but allow overriding of configuration via
--   command line arguments.
mainWith :: (Mutable a, ShowMutable a) => Args -> a -> (a -> [Property]) -> IO ()

-- | Same as <a>report</a>, but allow configuration via command line
--   arguments.
defaultMain :: (Mutable a, ShowMutable a) => a -> (a -> [Property]) -> IO ()
getArgs :: IO Args
getArgsWith :: Args -> IO Args
instance Data.Data.Data Test.FitSpec.Report.ShowMutantAs
instance Data.Data.Data Test.FitSpec.Report.Args


-- | <b> FitSpec: refining property-sets for functional testing </b>
--   
--   FitSpec provides automated assistance in the task of refining test
--   properties for Haskell functions. FitSpec tests mutant variations of
--   functions under test against a given property set, recording any
--   surviving mutants that pass all tests. FitSpec then reports:
--   
--   <ul>
--   <li><i>surviving mutants:</i> indicating incompleteness of properties,
--   prompting the user to amend a property or to add a new one;</li>
--   <li><i>conjectures:</i> indicating redundancy in the property set,
--   prompting the user to remove properties so to reduce the cost of
--   testing.</li>
--   </ul>
--   
--   Example, refining a <tt>sort</tt> specification:
--   
--   <pre>
--   import Test.FitSpec
--   import Data.List (sort)
--   
--   properties sort =
--     [ property $ \xs   -&gt; ordered (sort xs)
--     , property $ \xs   -&gt; length (sort xs) == length xs
--     , property $ \x xs -&gt; elem x (sort xs) == elem x xs
--     , property $ \x xs -&gt; notElem x (sort xs) == notElem x xs
--     , property $ \x xs -&gt; minimum (x:xs) == head (sort (x:xs))
--     ]
--     where
--     ordered (x:y:xs) = x &lt;= y &amp;&amp; ordered (y:xs)
--     ordered _        = True
--   
--   main = mainWith args { names = ["sort xs"]
--                        , nMutants = 4000
--                        , nTests   = 4000
--                        , timeout  = 0
--                        }
--                   (sort::[Word2]-&gt;[Word2])
--                   properties
--   </pre>
--   
--   The above program reports the following:
--   
--   <pre>
--   Apparent incomplete and non-minimal specification based on
--   4000 test cases for each of properties 1, 2, 3, 4 and 5
--   for each of 4000 mutant variations.
--   
--   3 survivors (99% killed), smallest:
--     \xs -&gt; case xs of
--              [0,0,1] -&gt; [0,1,1]
--              _ -&gt; sort xs
--   
--   apparent minimal property subsets:  {1,2,3} {1,2,4}
--   conjectures:  {3}    =  {4}     96% killed (weak)
--                 {1,3} ==&gt; {5}     98% killed (weak)
--   </pre>
module Test.FitSpec

-- | An encoded representation of a property suitable for use by FitSpec.
--   
--   Each list of strings is a printable representation of one possible
--   choice of argument values for the property. Each boolean indicate
--   whether the property holds for this choice.
type Property = [([String], Bool)]

-- | Given a <a>Testable</a> type (as defined by <a>Test.LeanCheck</a>),
--   returns a <a>Property</a>.
--   
--   This function should be used on every property to create a property
--   list to be passed to <tt>report</tt>, <tt>reportWith</tt>,
--   <tt>mainDefault</tt> or <tt>mainWith</tt>.
--   
--   <pre>
--   property $ \x y -&gt; x + y &lt; y + (x::Int)
--   </pre>
property :: Testable a => a -> Property

-- | Extra arguments / configuration for <a>reportWith</a>. See <a>args</a>
--   for default values.
data Args
Args :: Int -> Int -> Int -> [String] -> Bool -> ShowMutantAs -> Maybe Int -> [String] -> Args

-- | (starting) number of function mutations
[nMutants] :: Args -> Int

-- | (starting) number of test values (for each prop.)
[nTests] :: Args -> Int

-- | timeout in seconds, 0 for just <a>nTests</a> * <a>nMutants</a>
[timeout] :: Args -> Int

-- | names of functions: <tt>["foo x y","goo x y"]</tt>
[names] :: Args -> [String]

-- | whether to show detailed results
[verbose] :: Args -> Bool

-- | how to show mutants
[showMutantAs] :: Args -> ShowMutantAs

-- | number of surviving mutants to show
[rows] :: Args -> Maybe Int

-- | ignored argument (user defined meaning)
[extra] :: Args -> [String]

-- | How to show mutants. Use this to fill <a>showMutantAs</a>.
data ShowMutantAs
Tuple :: ShowMutantAs
NestedTuple :: ShowMutantAs
Definition :: ShowMutantAs
Bindings :: ShowMutantAs

-- | Default arguments for <a>reportWith</a>:
--   
--   <ul>
--   <li><tt>nMutants = 500</tt>, start with 500 mutants</li>
--   <li><tt>nTests = 1000</tt>, start with 1000 test values</li>
--   <li><tt>timeout = 5</tt>, keep incresing the number of mutants until 5
--   seconds elapse</li>
--   <li><tt>names = []</tt>, default function call template:</li>
--   </ul>
--   
--   <pre>
--   ["f x y z", "g x y z", "h x y z", ...]
--   </pre>
args :: Args

-- | Non timed-out default arguments. Make conjectures based on a fixed
--   number of mutants and tests, e.g.:
--   
--   <pre>
--   reportWith (fixargs 100 200) f pmap
--   </pre>
--   
--   This is just a shorthand, see:
--   
--   <pre>
--   fixargs nm nt  =  args { nMutants = nm, nTests = nt, timeout = 0 }
--   </pre>
--   
--   <pre>
--   (fixargs nm nt) { nMutants = 500, nTests = 1000, timeout = 5 }  =  args
--   </pre>
fixargs :: Int -> Int -> Args

-- | Report results generated by FitSpec. Uses standard configuration (see
--   <a>args</a>). Needs a function to be mutated and a property map.
--   Example (specification of boolean negation):
--   
--   <pre>
--   properties not =
--     [ property $ \p -&gt; not (not p) == p
--     , property $ \p -&gt; not (not (not p)) == not p
--     ]
--   
--   main = report not properties
--   </pre>
report :: (Mutable a, ShowMutable a) => a -> (a -> [Property]) -> IO ()

-- | Same as <a>report</a> but can be configured via <a>Args</a>
--   (<a>args</a> or <a>fixargs</a>), e.g.:
--   
--   <pre>
--   reportWith args { timeout = 10 } fun properties
--   </pre>
reportWith :: (Mutable a, ShowMutable a) => Args -> a -> (a -> [Property]) -> IO ()

-- | Same as <a>reportWith</a>, but accepts a list of manually defined
--   (extra) mutants to be tested alongside those automatically generated.
reportWithExtra :: (Mutable a, ShowMutable a) => [a] -> Args -> a -> (a -> [Property]) -> IO ()

-- | Same as <a>reportWith</a>, but allow overriding of configuration via
--   command line arguments.
mainWith :: (Mutable a, ShowMutable a) => Args -> a -> (a -> [Property]) -> IO ()

-- | Same as <a>report</a>, but allow configuration via command line
--   arguments.
defaultMain :: (Mutable a, ShowMutable a) => a -> (a -> [Property]) -> IO ()
getArgs :: IO Args
getArgsWith :: Args -> IO Args

-- | This typeclass is similar to <a>Listable</a>.
--   
--   A type is <a>Mutable</a> when there exists a function that is able to
--   list mutations of a value. Ideally: list all possible values without
--   repetitions.
--   
--   Instances are usually defined by a <a>mutiers</a> function that given
--   a value, returns tiers of mutants of that value: the first tier
--   contains the equivalent mutant, of size 0, the second tier contains
--   mutants of size 1, the third tier contains mutants of size 2, and so
--   on.
--   
--   The equivalent mutant is the actual function without mutations.
--   
--   The size of a mutant is given by the sum of: the number of mutated
--   points (relations) and the sizes of mutated arguments and results.
--   
--   To get only inequivalent mutants, just take the <a>tail</a> of either
--   <a>mutants</a> or <a>mutiers</a>:
--   
--   <pre>
--   tail mutants
--   </pre>
--   
--   <pre>
--   tail mutiers
--   </pre>
--   
--   Given that the underlying <a>Listable</a> enumeration has no
--   repetitions, parametric instances defined in this file will have no
--   repeated mutants.
class Mutable a
mutiers :: Mutable a => a -> [[a]]
mutants :: Mutable a => a -> [a]

-- | Implementation of <a>mutiers</a> for non-functional data types. Use
--   this to create instances for user-defined data types, e.g.:
--   
--   <pre>
--   instance MyData
--     where mutiers = mutiersEq
--   </pre>
--   
--   and for parametric datatypes:
--   
--   <pre>
--   instance (Eq a, Eq b) =&gt; MyDt a b
--     where mutiers = mutiersEq
--   </pre>
--   
--   Examples:
--   
--   <pre>
--   mutiersEq True = [[True], [False]]
--   mutiersEq 2   = [[2], [0], [1], [], [3], [4], [5], [6], [7], [8], [9], ...]
--   mutiersEq [1] = [[[1]], [[]], [[0]], [[0,0]], [[0,0,0],[0,1],[1,0],[-1]], ...]
--   </pre>
mutiersEq :: (Listable a, Eq a) => a -> [[a]]

-- | Types that can have their mutation shown. Has only one function
--   <a>mutantS</a> that returns a simple AST (<a>MutantS</a>) representing
--   the mutant. A standard implementation of <a>mutantS</a> for <a>Eq</a>
--   types is given by <a>mutantSEq</a>.
class ShowMutable a
mutantS :: ShowMutable a => a -> a -> MutantS

-- | For a given type <tt>Type</tt> instance of <tt>Eq</tt> and
--   <tt>Show</tt>, define the <a>ShowMutable</a> instance as:
--   
--   <pre>
--   instance ShowMutable Type
--     where mutantS = mutantSEq
--   </pre>
mutantSEq :: (Eq a, Show a) => a -> a -> MutantS

-- | Show a Mutant as a tuple of lambdas.
--   
--   <pre>
--   &gt; putStrLn $ showMutantAsTuple ["p &amp;&amp; q","not p"] ((&amp;&amp;),not) ((||),id)
--   ( \p q -&gt; case (p,q) of
--              (False,False) -&gt; True
--              _ -&gt; p &amp;&amp; q
--   , \p -&gt; case p of
--             False -&gt; False
--             True -&gt; True
--             _ -&gt; not p )
--   </pre>
--   
--   Can be easily copy pasted into an interactive session for
--   manipulation. On GHCi, use <tt>:{</tt> and <tt>:}</tt> to allow
--   multi-line expressions and definitions.
showMutantAsTuple :: ShowMutable a => [String] -> a -> a -> String

-- | Show a Mutant as a new complete top-level definition, with a prime
--   appended to the name of the mutant.
--   
--   <pre>
--   &gt; putStrLn $ showMutantDefinition ["p &amp;&amp; q","not p"] ((&amp;&amp;),not) ((==),id)
--   False &amp;&amp;- False = True
--   p     &amp;&amp;- q     = p &amp;&amp; q
--   not' False = False
--   not' True  = True
--   not' p     = not p
--   </pre>
showMutantDefinition :: ShowMutable a => [String] -> a -> a -> String

-- | Show a Mutant as a tuple of nested lambdas. Very similar to
--   <a>showMutantAsTuple</a>, but the underlying data structure is not
--   flatten: so the output is as close as possible to the underlying
--   representation.
showMutantNested :: ShowMutable a => [String] -> a -> a -> String

-- | Show a Mutant as the list of bindings that differ from the original
--   function(s).
--   
--   <pre>
--   &gt; putStrLn $ showMutantBindings ["p &amp;&amp; q","not p"] ((&amp;&amp;),not) ((==),id)
--   False &amp;&amp; False = True
--   not False = False
--   not True  = True
--   </pre>
--   
--   Can possibly be copied into the source of the original function for
--   manipulation.
showMutantBindings :: ShowMutable a => [String] -> a -> a -> String

-- | Derives <a>Mutable</a>, <a>ShowMutable</a> and (optionally)
--   <a>Listable</a> instances 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>
--   deriveMutable ''Stack
--   </pre>
--   
--   will automatically derive the following <a>Listable</a>,
--   <a>Mutable</a> and <a>ShowMutable</a> instances:
--   
--   <pre>
--   instance Listable a =&gt; Listable (Stack a) where
--     tiers = cons2 Stack \/ cons0 Empty
--   
--   instance (Eq a, Listable a) =&gt; Mutable a
--     where mutiers = mutiersEq
--   
--   instance (Eq a, Show a) =&gt; ShowMutable a
--     where mutantS = mutantSEq
--   </pre>
--   
--   If a <a>Listable</a> instance already exists, it is not derived. (cf.:
--   <a>deriveListable</a>)
--   
--   Needs the <tt>TemplateHaskell</tt> extension.
deriveMutable :: Name -> DecsQ

-- | Derives a Mutable instance for a given type <a>Name</a> using a given
--   context for all type variables.
deriveMutableE :: [Name] -> Name -> DecsQ
deriveMutableCascading :: Name -> DecsQ
deriveMutableCascadingE :: [Name] -> Name -> DecsQ
