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 |
Grisette.Internal.Core.Data.Class.TryMerge
Description
Synopsis
- class TryMerge (m :: Type -> Type) where
- tryMergeWithStrategy :: MergingStrategy a -> m a -> m a
- tryMerge :: (TryMerge m, Mergeable a) => m a -> m a
- type MonadTryMerge (f :: Type -> Type) = (TryMerge f, Monad f)
- mrgSingle :: (TryMerge m, Applicative m, Mergeable a) => a -> m a
- mrgSingleWithStrategy :: (TryMerge m, Applicative m) => MergingStrategy a -> a -> m a
- mrgToSym :: (ToSym a b, Mergeable b, TryMerge m, Applicative m) => a -> m b
- toUnionSym :: (ToSym a b, Mergeable b, TryMerge m, Applicative m) => a -> m b
Documentation
class TryMerge (m :: Type -> Type) 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.
Methods
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.
type MonadTryMerge (f :: Type -> Type) = (TryMerge f, Monad f) Source #
Alias for a monad type that has TryMerge
.
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" :: Union 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" :: Union 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.
mrgToSym :: (ToSym a b, Mergeable b, TryMerge m, Applicative m) => a -> m b Source #
Convert a value to symbolic value and wrap it with a mergeable container.
This is a synonym for toUnionSym
.
toUnionSym :: (ToSym a b, Mergeable b, TryMerge m, Applicative m) => a -> m b Source #
Convert a value to symbolic value and wrap it with a mergeable container.
This is a synonym for toUnionSym
.