darcs-2.18.2: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

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

- coalesce :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => (prim :> prim) wX wY -> Maybe (Maybe2 prim wX wY)
- defaultTryToShrink :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => FL prim wX wY -> Maybe (FL prim wX wY)
- defaultSortCoalesceFL :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => FL prim wX wY -> FL prim wX wY
- withAnyToMaybe :: (Any, a) -> Maybe a
- sortCoalesceFL2 :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => FL prim wX wY -> (Any, FL prim wX wY)

# Documentation

coalesce :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => (prim :> prim) wX wY -> Maybe (Maybe2 prim wX wY) #

Either `primCoalesce` or cancel inverses.

    primCoalesce (p :> q) == Just r => apply r = apply p >> apply q

defaultTryToShrink :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => FL prim wX wY -> Maybe (FL prim wX wY) #

defaultSortCoalesceFL :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => FL prim wX wY -> FL prim wX wY #

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

Conversion between `(`Any`, a)` and ``Maybe` a`.

sortCoalesceFL2 :: forall (prim :: Type -> Type -> Type) wX wY. PrimCoalesce prim => FL prim wX wY -> (Any, FL prim wX wY) #

The heart of `sortCoalesceFL`.