Copyright | (c) Sirui Lu 2023-2024 |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | siruilu@cs.washington.edu |
Stability | Experimental |
Portability | GHC only |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- class TryMerge m where
- tryMergeWithStrategy :: MergingStrategy a -> m a -> m a
- tryMerge :: (TryMerge m, Mergeable a) => m a -> m a
- type MonadTryMerge f = (TryMerge f, Monad f)
- mrgSingle :: (TryMerge m, Applicative m, Mergeable a) => a -> m a
- mrgSingleWithStrategy :: (TryMerge m, Applicative m) => MergingStrategy a -> a -> m a
Documentation
class TryMerge m where Source #
A class for containers that may or may not be merged.
If the container is capable of multi-path execution, then the
tryMergeWithStrategy
function should merge the paths according to the
supplied strategy.
If the container is not capable of multi-path execution, then the
tryMergeWithStrategy
function should be equivalent to id
.
Note that this will not necessarily do a recursive merge for the elements.
tryMergeWithStrategy :: MergingStrategy a -> m a -> m a Source #
Instances
tryMerge :: (TryMerge m, Mergeable a) => m a -> m a Source #
Try to merge the container with the root strategy.
mrgSingle :: (TryMerge m, Applicative m, Mergeable a) => a -> m a Source #
Wrap a value in the applicative functor and propagate the type's root merge strategy.
Equivalent to
.mrgSingleWithStrategy
rootStrategy
>>>
mrgSingle "a" :: UnionM SymInteger
{a}
mrgSingleWithStrategy :: (TryMerge m, Applicative m) => MergingStrategy a -> a -> m a Source #
Wrap a value in the applicative functor and capture the Mergeable
knowledge.
>>>
mrgSingleWithStrategy rootStrategy "a" :: UnionM SymInteger
{a}
Note: Be careful to call this directly from your code. The supplied merge strategy should be consistent with the type's root merge strategy, or some internal invariants would be broken and the program can crash.
This function is to be called when the Mergeable
constraint can not be
resolved, e.g., the merge strategy for the contained type is given with
Mergeable1
. In other cases, mrgPure
is usually a better alternative.