| Safe Haskell | Safe |
|---|---|
| Language | Haskell98 |
Numeric.Search.Combinator.Monadic
Description
Monadic binary search combinators.
- data Evidence a b
- = CounterExample a
- | Example b
- type Range b a = (b, (a, a))
- class InitializesSearch a x where
- initializeSearchM :: (Monad m, Eq b) => x -> (a -> m b) -> m [Range b a]
- type Splitter a = a -> a -> Maybe a
- splitForever :: Integral a => Splitter a
- splitTill :: Integral a => a -> Splitter a
- searchM :: forall a m b init. (Monad m, InitializesSearch a init, Eq b) => init -> Splitter a -> (a -> m b) -> m [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 where 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.
Methods
initializeSearchM :: (Monad m, Eq b) => x -> (a -> m b) -> m [Range b a] Source
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.
Searching
searchM :: forall a m b init. (Monad m, InitializesSearch a init, Eq b) => init -> Splitter a -> (a -> m b) -> m [Range b a] Source