Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Generic coalesce functions
Some of the algorithms in this module do complex recursive operations on sequences of patches in order to simplify them. These algorithms require that we know whether some intermediate step has made any progress. If not, we want to terminate or try something different.
We capture this as an effect by tagging intermediate data with the Any
monoid, a newtype wrapper for Bool
with disjunction as mappend
. The
standard instance
defined in the base package
then gives use the desired semantics. That is, when we sequence operations
using Monoid
a => Monad
(a,)'>>=
, the result tells us whether Any
of the two operations have
made progress.
Synopsis
- coalesce :: PrimCoalesce prim => (prim :> prim) wX wY -> Maybe (Maybe2 prim wX wY)
- defaultTryToShrink :: PrimCoalesce prim => FL prim wX wY -> Maybe (FL prim wX wY)
- defaultSortCoalesceFL :: PrimCoalesce prim => FL prim wX wY -> FL prim wX wY
- withAnyToMaybe :: (Any, a) -> Maybe a
- sortCoalesceFL2 :: PrimCoalesce prim => FL prim wX wY -> (Any, FL prim wX wY)
Documentation
coalesce :: PrimCoalesce prim => (prim :> prim) wX wY -> Maybe (Maybe2 prim wX wY) Source #
Either primCoalesce
or cancel inverses.
primCoalesce (p :> q) == Just r => apply r = apply p >> apply q
defaultTryToShrink :: PrimCoalesce prim => FL prim wX wY -> Maybe (FL prim wX wY) Source #
defaultSortCoalesceFL :: PrimCoalesce prim => FL prim wX wY -> FL prim wX wY Source #
sortCoalesceFL2 :: PrimCoalesce prim => FL prim wX wY -> (Any, FL prim wX wY) Source #
The heart of sortCoalesceFL
.