| Safe Haskell | Safe |
|---|---|
| Language | Haskell98 |
Numeric.Search.Combinator.Pure
Description
Pure counterpart for binary search.
- data Evidence a b
- = CounterExample a
- | Example b
- type Range b a = (b, (a, a))
- class InitializesSearch a x
- splitForever :: Integral a => Splitter a
- splitTill :: Integral a => a -> Splitter a
- search :: (InitializesSearch a init, Eq b) => init -> Splitter a -> (a -> b) -> [Range b a]
- smallest :: Eq b => b -> [Range b a] -> Maybe a
- largest :: Eq b => b -> [Range b a] -> Maybe a
Evidence
The Evidence datatype is similar to Either , but differes in that all CounterExample values are equal to each other, and all Example values are also equal to each other. The Evidence type is used to binary-searching for some predicate and meanwhile returning evidences for that.
Constructors
| CounterExample a | |
| Example b |
Search Range
class InitializesSearch a x Source
A type x is an instance of SearchInitializer a, if x can be used to set up the lower and upper inital values for binary search over values of type a. . initializeSearchM should generate a list of Range s, where each Range has different -- predicate.
Minimal complete definition
Instances
| InitializesSearch a ([a], [a]) Source | Set the lower and upper boundary from those available from the candidate lists. From the pair of list, the |
| InitializesSearch a ([a], a) Source | Set the upper boundary explicitly and search for the lower boundary. |
| InitializesSearch a (a, [a]) Source | Set the lower boundary explicitly and search for the upper boundary. |
| InitializesSearch a (a, a) Source | Set the lower and upper boundary explicitly. |
Splitters
splitForever :: Integral a => Splitter a Source
Perform split forever, until we cannot find a mid-value due to machine precision.
Search
search :: (InitializesSearch a init, Eq b) => init -> Splitter a -> (a -> b) -> [Range b a] Source
Perform search over pure predicates. The monadic version of this is searchM .