speculate-0.3.5: discovery of properties about Haskell functions

Copyright(c) 2016-2018 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellNone
LanguageHaskell2010

Test.Speculate.Function

Description

This module is part of Speculate.

If should import this if you want Speculate to treat functions as data values. This exports a Listable instance for functions an a facility to define Eq and Ord instances for functions.

Please see the fun and monad examples from Speculate's source repository for more details.

Synopsis

Documentation

funToList :: Listable a => (a -> b) -> [Maybe b] Source #

areEqualFor :: (Listable a, Eq b) => Int -> (a -> b) -> (a -> b) -> Bool Source #

This function can be used to define an Eq instance for functions based on testing and equality of returned values, like so:

instance (Listable a, Eq b) => Eq (a -> b) where
  (==) = areEqualFor 100

compareFor :: (Listable a, Ord b) => Int -> (a -> b) -> (a -> b) -> Ordering Source #

This function can be used to define an Ord instance for functions based on testing and ordering of returned values, like so:

instance (Listable a, Ord b) => Ord (a -> b) where
  compare = compareFor 100