darcs-2.18.4: a distributed, interactive, smart revision control system
Safe HaskellSafe-Inferred
LanguageHaskell2010

Darcs.Patch.Prim.Coalesce

Description

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 Monoid a => Monad (a,)' defined in the base package then gives use the desired semantics. That is, when we sequence operations using >>=, the result tells us whether Any of the two operations have made progress.

Synopsis

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 #

withAnyToMaybe :: (Any, a) -> Maybe a Source #

Conversion between (Any, a) and Maybe a.

sortCoalesceFL2 :: PrimCoalesce prim => FL prim wX wY -> (Any, FL prim wX wY) Source #

The heart of sortCoalesceFL.