Safe Haskell | None |
---|---|
Language | Haskell98 |
Generation of random shrinkable, showable functions. See the paper "Shrinking and showing functions" by Koen Claessen.
Example of use:
>>>
:{
>>>
let prop :: Fun String Integer -> Bool
>>>
prop (Fun _ f) = f "monkey" == f "banana" || f "banana" == f "elephant"
>>>
:}
>>>
quickCheck prop
*** Failed! Falsifiable (after 3 tests and 134 shrinks): {"elephant"->1, "monkey"->1, _->0}
To generate random values of type
,
you must have an instance Fun
a b
.
If your type has a Function
aShow
instance, you can use functionShow
to write the instance; otherwise,
use functionMap
to give a bijection between your type and a type that is already an instance of Function
.
See the
instance for an example of the latter.Function
[a]
- data Fun a b = Fun (a :-> b, b, Bool) (a -> b)
- apply :: Fun a b -> a -> b
- data a :-> c
- class Function a where
- functionMap :: Function b => (a -> b) -> (b -> a) -> (a -> c) -> a :-> c
- functionShow :: (Show a, Read a) => (a -> c) -> a :-> c
- functionIntegral :: Integral a => (a -> b) -> a :-> b
- functionRealFrac :: RealFrac a => (a -> b) -> a :-> b
- functionBoundedEnum :: (Eq a, Bounded a, Enum a) => (a -> b) -> a :-> b
- pattern Fn :: forall t t1. (t -> t1) -> Fun t t1
Documentation
The type of possibly partial concrete functions
class Function a where Source #
function :: (a -> b) -> a :-> b Source #
function :: (Generic a, GFunction (Rep a)) => (a -> b) -> a :-> b Source #
functionMap :: Function b => (a -> b) -> (b -> a) -> (a -> c) -> a :-> c Source #
functionIntegral :: Integral a => (a -> b) -> a :-> b Source #
functionRealFrac :: RealFrac a => (a -> b) -> a :-> b Source #