{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Grisette.Internal.Core.Data.Class.SimpleMergeable
(
SimpleMergeable (..),
SimpleMergeable1 (..),
mrgIte1,
SimpleMergeable2 (..),
mrgIte2,
UnionMergeable1 (..),
mrgIf,
mergeWithStrategy,
merge,
)
where
import Control.Monad.Except (ExceptT (ExceptT))
import Control.Monad.Identity
( Identity (Identity),
IdentityT (IdentityT),
)
import qualified Control.Monad.RWS.Lazy as RWSLazy
import qualified Control.Monad.RWS.Strict as RWSStrict
import Control.Monad.Reader (ReaderT (ReaderT))
import qualified Control.Monad.State.Lazy as StateLazy
import qualified Control.Monad.State.Strict as StateStrict
import Control.Monad.Trans.Cont (ContT (ContT))
import Control.Monad.Trans.Maybe (MaybeT (MaybeT))
import qualified Control.Monad.Writer.Lazy as WriterLazy
import qualified Control.Monad.Writer.Strict as WriterStrict
import Data.Kind (Type)
import GHC.Generics
( Generic (Rep, from, to),
K1 (K1),
M1 (M1),
U1,
V1,
type (:*:) ((:*:)),
)
import GHC.TypeNats (KnownNat, type (<=))
import Generics.Deriving (Default (Default))
import Grisette.Internal.Core.Control.Exception (AssertionError)
import Grisette.Internal.Core.Data.Class.ITEOp (ITEOp (symIte))
import Grisette.Internal.Core.Data.Class.Mergeable
( Mergeable (rootStrategy),
Mergeable',
Mergeable1 (liftRootStrategy),
Mergeable2 (liftRootStrategy2),
Mergeable3 (liftRootStrategy3),
MergingStrategy (SimpleStrategy),
)
import Grisette.Internal.Core.Data.Class.TryMerge (TryMerge (tryMergeWithStrategy))
import Grisette.Internal.SymPrim.GeneralFun (type (-->))
import Grisette.Internal.SymPrim.Prim.Term
( LinkedRep,
SupportedPrim,
)
import Grisette.Internal.SymPrim.SymBV
( SymIntN,
SymWordN,
)
import Grisette.Internal.SymPrim.SymBool (SymBool)
import Grisette.Internal.SymPrim.SymGeneralFun (type (-~>))
import Grisette.Internal.SymPrim.SymInteger (SymInteger)
import Grisette.Internal.SymPrim.SymTabularFun (type (=~>))
import Grisette.Internal.SymPrim.TabularFun (type (=->))
class SimpleMergeable' f where
mrgIte' :: SymBool -> f a -> f a -> f a
instance (SimpleMergeable' U1) where
mrgIte' :: forall a. SymBool -> U1 a -> U1 a -> U1 a
mrgIte' SymBool
_ U1 a
t U1 a
_ = U1 a
t
{-# INLINE mrgIte' #-}
instance (SimpleMergeable' V1) where
mrgIte' :: forall a. SymBool -> V1 a -> V1 a -> V1 a
mrgIte' SymBool
_ V1 a
t V1 a
_ = V1 a
t
{-# INLINE mrgIte' #-}
instance (SimpleMergeable c) => (SimpleMergeable' (K1 i c)) where
mrgIte' :: forall a. SymBool -> K1 i c a -> K1 i c a -> K1 i c a
mrgIte' SymBool
cond (K1 c
a) (K1 c
b) = c -> K1 i c a
forall k i c (p :: k). c -> K1 i c p
K1 (c -> K1 i c a) -> c -> K1 i c a
forall a b. (a -> b) -> a -> b
$ SymBool -> c -> c -> c
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond c
a c
b
{-# INLINE mrgIte' #-}
instance (SimpleMergeable' a) => (SimpleMergeable' (M1 i c a)) where
mrgIte' :: forall a. SymBool -> M1 i c a a -> M1 i c a a -> M1 i c a a
mrgIte' SymBool
cond (M1 a a
a) (M1 a a
b) = a a -> M1 i c a a
forall k i (c :: Meta) (f :: k -> *) (p :: k). f p -> M1 i c f p
M1 (a a -> M1 i c a a) -> a a -> M1 i c a a
forall a b. (a -> b) -> a -> b
$ SymBool -> a a -> a a -> a a
forall a. SymBool -> a a -> a a -> a a
forall (f :: * -> *) a.
SimpleMergeable' f =>
SymBool -> f a -> f a -> f a
mrgIte' SymBool
cond a a
a a a
b
{-# INLINE mrgIte' #-}
instance (SimpleMergeable' a, SimpleMergeable' b) => (SimpleMergeable' (a :*: b)) where
mrgIte' :: forall a. SymBool -> (:*:) a b a -> (:*:) a b a -> (:*:) a b a
mrgIte' SymBool
cond (a a
a1 :*: b a
a2) (a a
b1 :*: b a
b2) = SymBool -> a a -> a a -> a a
forall a. SymBool -> a a -> a a -> a a
forall (f :: * -> *) a.
SimpleMergeable' f =>
SymBool -> f a -> f a -> f a
mrgIte' SymBool
cond a a
a1 a a
b1 a a -> b a -> (:*:) a b a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
:*: SymBool -> b a -> b a -> b a
forall a. SymBool -> b a -> b a -> b a
forall (f :: * -> *) a.
SimpleMergeable' f =>
SymBool -> f a -> f a -> f a
mrgIte' SymBool
cond b a
a2 b a
b2
{-# INLINE mrgIte' #-}
class (Mergeable a) => SimpleMergeable a where
mrgIte :: SymBool -> a -> a -> a
instance (Generic a, Mergeable' (Rep a), SimpleMergeable' (Rep a)) => SimpleMergeable (Default a) where
mrgIte :: SymBool -> Default a -> Default a -> Default a
mrgIte SymBool
cond (Default a
a) (Default a
b) = a -> Default a
forall a. a -> Default a
Default (a -> Default a) -> a -> Default a
forall a b. (a -> b) -> a -> b
$ Rep a Any -> a
forall a x. Generic a => Rep a x -> a
forall x. Rep a x -> a
to (Rep a Any -> a) -> Rep a Any -> a
forall a b. (a -> b) -> a -> b
$ SymBool -> Rep a Any -> Rep a Any -> Rep a Any
forall a. SymBool -> Rep a a -> Rep a a -> Rep a a
forall (f :: * -> *) a.
SimpleMergeable' f =>
SymBool -> f a -> f a -> f a
mrgIte' SymBool
cond (a -> Rep a Any
forall x. a -> Rep a x
forall a x. Generic a => a -> Rep a x
from a
a) (a -> Rep a Any
forall x. a -> Rep a x
forall a x. Generic a => a -> Rep a x
from a
b)
{-# INLINE mrgIte #-}
class (Mergeable1 u) => SimpleMergeable1 u where
liftMrgIte :: (SymBool -> a -> a -> a) -> SymBool -> u a -> u a -> u a
mrgIte1 :: (SimpleMergeable1 u, SimpleMergeable a) => SymBool -> u a -> u a -> u a
mrgIte1 :: forall (u :: * -> *) a.
(SimpleMergeable1 u, SimpleMergeable a) =>
SymBool -> u a -> u a -> u a
mrgIte1 = (SymBool -> a -> a -> a) -> SymBool -> u a -> u a -> u a
forall a. (SymBool -> a -> a -> a) -> SymBool -> u a -> u a -> u a
forall (u :: * -> *) a.
SimpleMergeable1 u =>
(SymBool -> a -> a -> a) -> SymBool -> u a -> u a -> u a
liftMrgIte SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte
{-# INLINE mrgIte1 #-}
class (Mergeable2 u) => SimpleMergeable2 u where
liftMrgIte2 :: (SymBool -> a -> a -> a) -> (SymBool -> b -> b -> b) -> SymBool -> u a b -> u a b -> u a b
mrgIte2 :: (SimpleMergeable2 u, SimpleMergeable a, SimpleMergeable b) => SymBool -> u a b -> u a b -> u a b
mrgIte2 :: forall (u :: * -> * -> *) a b.
(SimpleMergeable2 u, SimpleMergeable a, SimpleMergeable b) =>
SymBool -> u a b -> u a b -> u a b
mrgIte2 = (SymBool -> a -> a -> a)
-> (SymBool -> b -> b -> b) -> SymBool -> u a b -> u a b -> u a b
forall a b.
(SymBool -> a -> a -> a)
-> (SymBool -> b -> b -> b) -> SymBool -> u a b -> u a b -> u a b
forall (u :: * -> * -> *) a b.
SimpleMergeable2 u =>
(SymBool -> a -> a -> a)
-> (SymBool -> b -> b -> b) -> SymBool -> u a b -> u a b -> u a b
liftMrgIte2 SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool -> b -> b -> b
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte
{-# INLINE mrgIte2 #-}
class (SimpleMergeable1 u, TryMerge u) => UnionMergeable1 (u :: Type -> Type) where
mrgIfWithStrategy :: MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy :: SymBool -> u a -> u a -> u a
mergeWithStrategy :: (UnionMergeable1 m) => MergingStrategy a -> m a -> m a
mergeWithStrategy :: forall (m :: * -> *) a.
UnionMergeable1 m =>
MergingStrategy a -> m a -> m a
mergeWithStrategy = MergingStrategy a -> m a -> m a
forall a. MergingStrategy a -> m a -> m a
forall (m :: * -> *) a.
TryMerge m =>
MergingStrategy a -> m a -> m a
tryMergeWithStrategy
{-# INLINE mergeWithStrategy #-}
merge :: (UnionMergeable1 m, Mergeable a) => m a -> m a
merge :: forall (m :: * -> *) a.
(UnionMergeable1 m, Mergeable a) =>
m a -> m a
merge = MergingStrategy a -> m a -> m a
forall (m :: * -> *) a.
UnionMergeable1 m =>
MergingStrategy a -> m a -> m a
mergeWithStrategy MergingStrategy a
forall a. Mergeable a => MergingStrategy a
rootStrategy
{-# INLINE merge #-}
mrgIf :: (UnionMergeable1 u, Mergeable a) => SymBool -> u a -> u a -> u a
mrgIf :: forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf = MergingStrategy a -> SymBool -> u a -> u a -> u a
forall a. MergingStrategy a -> SymBool -> u a -> u a -> u a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy MergingStrategy a
forall a. Mergeable a => MergingStrategy a
rootStrategy
{-# INLINE mrgIf #-}
instance SimpleMergeable () where
mrgIte :: SymBool -> () -> () -> ()
mrgIte SymBool
_ ()
t ()
_ = ()
t
{-# INLINE mrgIte #-}
instance (SimpleMergeable a, SimpleMergeable b) => SimpleMergeable (a, b) where
mrgIte :: SymBool -> (a, b) -> (a, b) -> (a, b)
mrgIte SymBool
cond (a
a1, b
b1) (a
a2, b
b2) = (SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond a
a1 a
a2, SymBool -> b -> b -> b
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond b
b1 b
b2)
{-# INLINE mrgIte #-}
instance (SimpleMergeable a) => SimpleMergeable1 ((,) a) where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a) -> SymBool -> (a, a) -> (a, a) -> (a, a)
liftMrgIte SymBool -> a -> a -> a
mb SymBool
cond (a
a1, a
b1) (a
a2, a
b2) = (SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond a
a1 a
a2, SymBool -> a -> a -> a
mb SymBool
cond a
b1 a
b2)
{-# INLINE liftMrgIte #-}
instance SimpleMergeable2 (,) where
liftMrgIte2 :: forall a b.
(SymBool -> a -> a -> a)
-> (SymBool -> b -> b -> b)
-> SymBool
-> (a, b)
-> (a, b)
-> (a, b)
liftMrgIte2 SymBool -> a -> a -> a
ma SymBool -> b -> b -> b
mb SymBool
cond (a
a1, b
b1) (a
a2, b
b2) = (SymBool -> a -> a -> a
ma SymBool
cond a
a1 a
a2, SymBool -> b -> b -> b
mb SymBool
cond b
b1 b
b2)
{-# INLINE liftMrgIte2 #-}
instance
(SimpleMergeable a, SimpleMergeable b, SimpleMergeable c) =>
SimpleMergeable (a, b, c)
where
mrgIte :: SymBool -> (a, b, c) -> (a, b, c) -> (a, b, c)
mrgIte SymBool
cond (a
a1, b
b1, c
c1) (a
a2, b
b2, c
c2) = (SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond a
a1 a
a2, SymBool -> b -> b -> b
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond b
b1 b
b2, SymBool -> c -> c -> c
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond c
c1 c
c2)
{-# INLINE mrgIte #-}
instance
( SimpleMergeable a,
SimpleMergeable b,
SimpleMergeable c,
SimpleMergeable d
) =>
SimpleMergeable (a, b, c, d)
where
mrgIte :: SymBool -> (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d)
mrgIte SymBool
cond (a
a1, b
b1, c
c1, d
d1) (a
a2, b
b2, c
c2, d
d2) =
(SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond a
a1 a
a2, SymBool -> b -> b -> b
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond b
b1 b
b2, SymBool -> c -> c -> c
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond c
c1 c
c2, SymBool -> d -> d -> d
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond d
d1 d
d2)
{-# INLINE mrgIte #-}
instance
( SimpleMergeable a,
SimpleMergeable b,
SimpleMergeable c,
SimpleMergeable d,
SimpleMergeable e
) =>
SimpleMergeable (a, b, c, d, e)
where
mrgIte :: SymBool -> (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e)
mrgIte SymBool
cond (a
a1, b
b1, c
c1, d
d1, e
e1) (a
a2, b
b2, c
c2, d
d2, e
e2) =
(SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond a
a1 a
a2, SymBool -> b -> b -> b
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond b
b1 b
b2, SymBool -> c -> c -> c
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond c
c1 c
c2, SymBool -> d -> d -> d
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond d
d1 d
d2, SymBool -> e -> e -> e
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond e
e1 e
e2)
{-# INLINE mrgIte #-}
instance
( SimpleMergeable a,
SimpleMergeable b,
SimpleMergeable c,
SimpleMergeable d,
SimpleMergeable e,
SimpleMergeable f
) =>
SimpleMergeable (a, b, c, d, e, f)
where
mrgIte :: SymBool
-> (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f)
mrgIte SymBool
cond (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1) (a
a2, b
b2, c
c2, d
d2, e
e2, f
f2) =
(SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond a
a1 a
a2, SymBool -> b -> b -> b
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond b
b1 b
b2, SymBool -> c -> c -> c
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond c
c1 c
c2, SymBool -> d -> d -> d
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond d
d1 d
d2, SymBool -> e -> e -> e
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond e
e1 e
e2, SymBool -> f -> f -> f
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond f
f1 f
f2)
{-# INLINE mrgIte #-}
instance
( SimpleMergeable a,
SimpleMergeable b,
SimpleMergeable c,
SimpleMergeable d,
SimpleMergeable e,
SimpleMergeable f,
SimpleMergeable g
) =>
SimpleMergeable (a, b, c, d, e, f, g)
where
mrgIte :: SymBool
-> (a, b, c, d, e, f, g)
-> (a, b, c, d, e, f, g)
-> (a, b, c, d, e, f, g)
mrgIte SymBool
cond (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1, g
g1) (a
a2, b
b2, c
c2, d
d2, e
e2, f
f2, g
g2) =
( SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond a
a1 a
a2,
SymBool -> b -> b -> b
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond b
b1 b
b2,
SymBool -> c -> c -> c
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond c
c1 c
c2,
SymBool -> d -> d -> d
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond d
d1 d
d2,
SymBool -> e -> e -> e
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond e
e1 e
e2,
SymBool -> f -> f -> f
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond f
f1 f
f2,
SymBool -> g -> g -> g
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond g
g1 g
g2
)
{-# INLINE mrgIte #-}
instance
( SimpleMergeable a,
SimpleMergeable b,
SimpleMergeable c,
SimpleMergeable d,
SimpleMergeable e,
SimpleMergeable f,
SimpleMergeable g,
SimpleMergeable h
) =>
SimpleMergeable (a, b, c, d, e, f, g, h)
where
mrgIte :: SymBool
-> (a, b, c, d, e, f, g, h)
-> (a, b, c, d, e, f, g, h)
-> (a, b, c, d, e, f, g, h)
mrgIte SymBool
cond (a
a1, b
b1, c
c1, d
d1, e
e1, f
f1, g
g1, h
h1) (a
a2, b
b2, c
c2, d
d2, e
e2, f
f2, g
g2, h
h2) =
( SymBool -> a -> a -> a
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond a
a1 a
a2,
SymBool -> b -> b -> b
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond b
b1 b
b2,
SymBool -> c -> c -> c
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond c
c1 c
c2,
SymBool -> d -> d -> d
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond d
d1 d
d2,
SymBool -> e -> e -> e
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond e
e1 e
e2,
SymBool -> f -> f -> f
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond f
f1 f
f2,
SymBool -> g -> g -> g
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond g
g1 g
g2,
SymBool -> h -> h -> h
forall a. SimpleMergeable a => SymBool -> a -> a -> a
mrgIte SymBool
cond h
h1 h
h2
)
{-# INLINE mrgIte #-}
instance (SimpleMergeable b) => SimpleMergeable (a -> b) where
mrgIte :: SymBool -> (a -> b) -> (a -> b) -> a -> b
mrgIte = SymBool -> (a -> b) -> (a -> b) -> a -> b
forall (u :: * -> *) a.
(SimpleMergeable1 u, SimpleMergeable a) =>
SymBool -> u a -> u a -> u a
mrgIte1
{-# INLINE mrgIte #-}
instance SimpleMergeable1 ((->) a) where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> (a -> a) -> (a -> a) -> a -> a
liftMrgIte SymBool -> a -> a -> a
ms SymBool
cond a -> a
t a -> a
f a
v = SymBool -> a -> a -> a
ms SymBool
cond (a -> a
t a
v) (a -> a
f a
v)
{-# INLINE liftMrgIte #-}
instance (UnionMergeable1 m, Mergeable a) => SimpleMergeable (MaybeT m a) where
mrgIte :: SymBool -> MaybeT m a -> MaybeT m a -> MaybeT m a
mrgIte = SymBool -> MaybeT m a -> MaybeT m a -> MaybeT m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance (UnionMergeable1 m) => SimpleMergeable1 (MaybeT m) where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> MaybeT m a -> MaybeT m a -> MaybeT m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> MaybeT m a -> MaybeT m a -> MaybeT m a
forall a.
MergingStrategy a
-> SymBool -> MaybeT m a -> MaybeT m a -> MaybeT m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance (UnionMergeable1 m) => UnionMergeable1 (MaybeT m) where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> MaybeT m a -> MaybeT m a -> MaybeT m a
mrgIfWithStrategy MergingStrategy a
strategy SymBool
cond (MaybeT m (Maybe a)
l) (MaybeT m (Maybe a)
r) =
m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe a) -> MaybeT m a) -> m (Maybe a) -> MaybeT m a
forall a b. (a -> b) -> a -> b
$ MergingStrategy (Maybe a)
-> SymBool -> m (Maybe a) -> m (Maybe a) -> m (Maybe a)
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy (MergingStrategy a -> MergingStrategy (Maybe a)
forall a. MergingStrategy a -> MergingStrategy (Maybe a)
forall (u :: * -> *) a.
Mergeable1 u =>
MergingStrategy a -> MergingStrategy (u a)
liftRootStrategy MergingStrategy a
strategy) SymBool
cond m (Maybe a)
l m (Maybe a)
r
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a. SymBool -> MaybeT m a -> MaybeT m a -> MaybeT m a
mrgIfPropagatedStrategy SymBool
cond (MaybeT m (Maybe a)
l) (MaybeT m (Maybe a)
r) =
m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe a) -> MaybeT m a) -> m (Maybe a) -> MaybeT m a
forall a b. (a -> b) -> a -> b
$ SymBool -> m (Maybe a) -> m (Maybe a) -> m (Maybe a)
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond m (Maybe a)
l m (Maybe a)
r
{-# INLINE mrgIfPropagatedStrategy #-}
instance
(UnionMergeable1 m, Mergeable e, Mergeable a) =>
SimpleMergeable (ExceptT e m a)
where
mrgIte :: SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a
mrgIte = SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance
(UnionMergeable1 m, Mergeable e) =>
SimpleMergeable1 (ExceptT e m)
where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a
forall a.
MergingStrategy a
-> SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance
(UnionMergeable1 m, Mergeable e) =>
UnionMergeable1 (ExceptT e m)
where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a
mrgIfWithStrategy MergingStrategy a
s SymBool
cond (ExceptT m (Either e a)
t) (ExceptT m (Either e a)
f) =
m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ MergingStrategy (Either e a)
-> SymBool -> m (Either e a) -> m (Either e a) -> m (Either e a)
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy (MergingStrategy a -> MergingStrategy (Either e a)
forall a. MergingStrategy a -> MergingStrategy (Either e a)
forall (u :: * -> *) a.
Mergeable1 u =>
MergingStrategy a -> MergingStrategy (u a)
liftRootStrategy MergingStrategy a
s) SymBool
cond m (Either e a)
t m (Either e a)
f
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a.
SymBool -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a
mrgIfPropagatedStrategy SymBool
cond (ExceptT m (Either e a)
t) (ExceptT m (Either e a)
f) =
m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ SymBool -> m (Either e a) -> m (Either e a) -> m (Either e a)
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond m (Either e a)
t m (Either e a)
f
{-# INLINE mrgIfPropagatedStrategy #-}
instance
(Mergeable s, Mergeable a, UnionMergeable1 m) =>
SimpleMergeable (StateLazy.StateT s m a)
where
mrgIte :: SymBool -> StateT s m a -> StateT s m a -> StateT s m a
mrgIte = SymBool -> StateT s m a -> StateT s m a -> StateT s m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance
(Mergeable s, UnionMergeable1 m) =>
SimpleMergeable1 (StateLazy.StateT s m)
where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> StateT s m a -> StateT s m a -> StateT s m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> StateT s m a -> StateT s m a -> StateT s m a
forall a.
MergingStrategy a
-> SymBool -> StateT s m a -> StateT s m a -> StateT s m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance
(Mergeable s, UnionMergeable1 m) =>
UnionMergeable1 (StateLazy.StateT s m)
where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> StateT s m a -> StateT s m a -> StateT s m a
mrgIfWithStrategy MergingStrategy a
s SymBool
cond (StateLazy.StateT s -> m (a, s)
t) (StateLazy.StateT s -> m (a, s)
f) =
(s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateLazy.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
v ->
MergingStrategy (a, s)
-> SymBool -> m (a, s) -> m (a, s) -> m (a, s)
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy
(MergingStrategy a -> MergingStrategy s -> MergingStrategy (a, s)
forall a b.
MergingStrategy a -> MergingStrategy b -> MergingStrategy (a, b)
forall (u :: * -> * -> *) a b.
Mergeable2 u =>
MergingStrategy a -> MergingStrategy b -> MergingStrategy (u a b)
liftRootStrategy2 MergingStrategy a
s MergingStrategy s
forall a. Mergeable a => MergingStrategy a
rootStrategy)
SymBool
cond
(s -> m (a, s)
t s
v)
(s -> m (a, s)
f s
v)
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a. SymBool -> StateT s m a -> StateT s m a -> StateT s m a
mrgIfPropagatedStrategy SymBool
cond (StateLazy.StateT s -> m (a, s)
t) (StateLazy.StateT s -> m (a, s)
f) =
(s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateLazy.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
v -> SymBool -> m (a, s) -> m (a, s) -> m (a, s)
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond (s -> m (a, s)
t s
v) (s -> m (a, s)
f s
v)
{-# INLINE mrgIfPropagatedStrategy #-}
instance
(Mergeable s, Mergeable a, UnionMergeable1 m) =>
SimpleMergeable (StateStrict.StateT s m a)
where
mrgIte :: SymBool -> StateT s m a -> StateT s m a -> StateT s m a
mrgIte = SymBool -> StateT s m a -> StateT s m a -> StateT s m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance
(Mergeable s, UnionMergeable1 m) =>
SimpleMergeable1 (StateStrict.StateT s m)
where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> StateT s m a -> StateT s m a -> StateT s m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> StateT s m a -> StateT s m a -> StateT s m a
forall a.
MergingStrategy a
-> SymBool -> StateT s m a -> StateT s m a -> StateT s m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance
(Mergeable s, UnionMergeable1 m) =>
UnionMergeable1 (StateStrict.StateT s m)
where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> StateT s m a -> StateT s m a -> StateT s m a
mrgIfWithStrategy MergingStrategy a
s SymBool
cond (StateStrict.StateT s -> m (a, s)
t) (StateStrict.StateT s -> m (a, s)
f) =
(s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateStrict.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$
\s
v ->
MergingStrategy (a, s)
-> SymBool -> m (a, s) -> m (a, s) -> m (a, s)
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy (MergingStrategy a -> MergingStrategy s -> MergingStrategy (a, s)
forall a b.
MergingStrategy a -> MergingStrategy b -> MergingStrategy (a, b)
forall (u :: * -> * -> *) a b.
Mergeable2 u =>
MergingStrategy a -> MergingStrategy b -> MergingStrategy (u a b)
liftRootStrategy2 MergingStrategy a
s MergingStrategy s
forall a. Mergeable a => MergingStrategy a
rootStrategy) SymBool
cond (s -> m (a, s)
t s
v) (s -> m (a, s)
f s
v)
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a. SymBool -> StateT s m a -> StateT s m a -> StateT s m a
mrgIfPropagatedStrategy SymBool
cond (StateStrict.StateT s -> m (a, s)
t) (StateStrict.StateT s -> m (a, s)
f) =
(s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateStrict.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
v -> SymBool -> m (a, s) -> m (a, s) -> m (a, s)
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond (s -> m (a, s)
t s
v) (s -> m (a, s)
f s
v)
{-# INLINE mrgIfPropagatedStrategy #-}
instance
(Mergeable s, Mergeable a, UnionMergeable1 m, Monoid s) =>
SimpleMergeable (WriterLazy.WriterT s m a)
where
mrgIte :: SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
mrgIte = SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance
(Mergeable s, UnionMergeable1 m, Monoid s) =>
SimpleMergeable1 (WriterLazy.WriterT s m)
where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
forall a.
MergingStrategy a
-> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance
(Mergeable s, UnionMergeable1 m, Monoid s) =>
UnionMergeable1 (WriterLazy.WriterT s m)
where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
mrgIfWithStrategy MergingStrategy a
s SymBool
cond (WriterLazy.WriterT m (a, s)
t) (WriterLazy.WriterT m (a, s)
f) =
m (a, s) -> WriterT s m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
WriterLazy.WriterT (m (a, s) -> WriterT s m a) -> m (a, s) -> WriterT s m a
forall a b. (a -> b) -> a -> b
$
MergingStrategy (a, s)
-> SymBool -> m (a, s) -> m (a, s) -> m (a, s)
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy (MergingStrategy a -> MergingStrategy s -> MergingStrategy (a, s)
forall a b.
MergingStrategy a -> MergingStrategy b -> MergingStrategy (a, b)
forall (u :: * -> * -> *) a b.
Mergeable2 u =>
MergingStrategy a -> MergingStrategy b -> MergingStrategy (u a b)
liftRootStrategy2 MergingStrategy a
s MergingStrategy s
forall a. Mergeable a => MergingStrategy a
rootStrategy) SymBool
cond m (a, s)
t m (a, s)
f
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a.
SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
mrgIfPropagatedStrategy SymBool
cond (WriterLazy.WriterT m (a, s)
t) (WriterLazy.WriterT m (a, s)
f) =
m (a, s) -> WriterT s m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
WriterLazy.WriterT (m (a, s) -> WriterT s m a) -> m (a, s) -> WriterT s m a
forall a b. (a -> b) -> a -> b
$ SymBool -> m (a, s) -> m (a, s) -> m (a, s)
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond m (a, s)
t m (a, s)
f
{-# INLINE mrgIfPropagatedStrategy #-}
instance
(Mergeable s, Mergeable a, UnionMergeable1 m, Monoid s) =>
SimpleMergeable (WriterStrict.WriterT s m a)
where
mrgIte :: SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
mrgIte = SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance
(Mergeable s, UnionMergeable1 m, Monoid s) =>
SimpleMergeable1 (WriterStrict.WriterT s m)
where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
forall a.
MergingStrategy a
-> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance
(Mergeable s, UnionMergeable1 m, Monoid s) =>
UnionMergeable1 (WriterStrict.WriterT s m)
where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
mrgIfWithStrategy MergingStrategy a
s SymBool
cond (WriterStrict.WriterT m (a, s)
t) (WriterStrict.WriterT m (a, s)
f) =
m (a, s) -> WriterT s m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
WriterStrict.WriterT (m (a, s) -> WriterT s m a) -> m (a, s) -> WriterT s m a
forall a b. (a -> b) -> a -> b
$
MergingStrategy (a, s)
-> SymBool -> m (a, s) -> m (a, s) -> m (a, s)
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy (MergingStrategy a -> MergingStrategy s -> MergingStrategy (a, s)
forall a b.
MergingStrategy a -> MergingStrategy b -> MergingStrategy (a, b)
forall (u :: * -> * -> *) a b.
Mergeable2 u =>
MergingStrategy a -> MergingStrategy b -> MergingStrategy (u a b)
liftRootStrategy2 MergingStrategy a
s MergingStrategy s
forall a. Mergeable a => MergingStrategy a
rootStrategy) SymBool
cond m (a, s)
t m (a, s)
f
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a.
SymBool -> WriterT s m a -> WriterT s m a -> WriterT s m a
mrgIfPropagatedStrategy SymBool
cond (WriterStrict.WriterT m (a, s)
t) (WriterStrict.WriterT m (a, s)
f) =
m (a, s) -> WriterT s m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
WriterStrict.WriterT (m (a, s) -> WriterT s m a) -> m (a, s) -> WriterT s m a
forall a b. (a -> b) -> a -> b
$ SymBool -> m (a, s) -> m (a, s) -> m (a, s)
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond m (a, s)
t m (a, s)
f
{-# INLINE mrgIfPropagatedStrategy #-}
instance
(Mergeable a, UnionMergeable1 m) =>
SimpleMergeable (ReaderT s m a)
where
mrgIte :: SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a
mrgIte = SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance
(UnionMergeable1 m) =>
SimpleMergeable1 (ReaderT s m)
where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a
forall a.
MergingStrategy a
-> SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance
(UnionMergeable1 m) =>
UnionMergeable1 (ReaderT s m)
where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a
mrgIfWithStrategy MergingStrategy a
s SymBool
cond (ReaderT s -> m a
t) (ReaderT s -> m a
f) =
(s -> m a) -> ReaderT s m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((s -> m a) -> ReaderT s m a) -> (s -> m a) -> ReaderT s m a
forall a b. (a -> b) -> a -> b
$ \s
v -> MergingStrategy a -> SymBool -> m a -> m a -> m a
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy MergingStrategy a
s SymBool
cond (s -> m a
t s
v) (s -> m a
f s
v)
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a.
SymBool -> ReaderT s m a -> ReaderT s m a -> ReaderT s m a
mrgIfPropagatedStrategy SymBool
cond (ReaderT s -> m a
t) (ReaderT s -> m a
f) =
(s -> m a) -> ReaderT s m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((s -> m a) -> ReaderT s m a) -> (s -> m a) -> ReaderT s m a
forall a b. (a -> b) -> a -> b
$ \s
v -> SymBool -> m a -> m a -> m a
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond (s -> m a
t s
v) (s -> m a
f s
v)
{-# INLINE mrgIfPropagatedStrategy #-}
instance (SimpleMergeable a) => SimpleMergeable (Identity a) where
mrgIte :: SymBool -> Identity a -> Identity a -> Identity a
mrgIte = SymBool -> Identity a -> Identity a -> Identity a
forall (u :: * -> *) a.
(SimpleMergeable1 u, SimpleMergeable a) =>
SymBool -> u a -> u a -> u a
mrgIte1
{-# INLINE mrgIte #-}
instance SimpleMergeable1 Identity where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> Identity a -> Identity a -> Identity a
liftMrgIte SymBool -> a -> a -> a
mite SymBool
cond (Identity a
l) (Identity a
r) = a -> Identity a
forall a. a -> Identity a
Identity (a -> Identity a) -> a -> Identity a
forall a b. (a -> b) -> a -> b
$ SymBool -> a -> a -> a
mite SymBool
cond a
l a
r
{-# INLINE liftMrgIte #-}
instance
(UnionMergeable1 m, Mergeable a) =>
SimpleMergeable (IdentityT m a)
where
mrgIte :: SymBool -> IdentityT m a -> IdentityT m a -> IdentityT m a
mrgIte = SymBool -> IdentityT m a -> IdentityT m a -> IdentityT m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance (UnionMergeable1 m) => SimpleMergeable1 (IdentityT m) where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> IdentityT m a -> IdentityT m a -> IdentityT m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> IdentityT m a -> IdentityT m a -> IdentityT m a
forall a.
MergingStrategy a
-> SymBool -> IdentityT m a -> IdentityT m a -> IdentityT m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance (UnionMergeable1 m) => UnionMergeable1 (IdentityT m) where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> IdentityT m a -> IdentityT m a -> IdentityT m a
mrgIfWithStrategy MergingStrategy a
s SymBool
cond (IdentityT m a
l) (IdentityT m a
r) =
m a -> IdentityT m a
forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a) -> m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$ MergingStrategy a -> SymBool -> m a -> m a -> m a
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy MergingStrategy a
s SymBool
cond m a
l m a
r
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a.
SymBool -> IdentityT m a -> IdentityT m a -> IdentityT m a
mrgIfPropagatedStrategy SymBool
cond (IdentityT m a
l) (IdentityT m a
r) =
m a -> IdentityT m a
forall {k} (f :: k -> *) (a :: k). f a -> IdentityT f a
IdentityT (m a -> IdentityT m a) -> m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$ SymBool -> m a -> m a -> m a
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond m a
l m a
r
{-# INLINE mrgIfPropagatedStrategy #-}
instance (UnionMergeable1 m, Mergeable r) => SimpleMergeable (ContT r m a) where
mrgIte :: SymBool -> ContT r m a -> ContT r m a -> ContT r m a
mrgIte SymBool
cond (ContT (a -> m r) -> m r
l) (ContT (a -> m r) -> m r
r) = ((a -> m r) -> m r) -> ContT r m a
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((a -> m r) -> m r) -> ContT r m a)
-> ((a -> m r) -> m r) -> ContT r m a
forall a b. (a -> b) -> a -> b
$ \a -> m r
c -> SymBool -> m r -> m r -> m r
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf SymBool
cond ((a -> m r) -> m r
l a -> m r
c) ((a -> m r) -> m r
r a -> m r
c)
{-# INLINE mrgIte #-}
instance (UnionMergeable1 m, Mergeable r) => SimpleMergeable1 (ContT r m) where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> ContT r m a -> ContT r m a -> ContT r m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> ContT r m a -> ContT r m a -> ContT r m a
forall a.
MergingStrategy a
-> SymBool -> ContT r m a -> ContT r m a -> ContT r m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance (UnionMergeable1 m, Mergeable r) => UnionMergeable1 (ContT r m) where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> ContT r m a -> ContT r m a -> ContT r m a
mrgIfWithStrategy MergingStrategy a
_ SymBool
cond (ContT (a -> m r) -> m r
l) (ContT (a -> m r) -> m r
r) =
((a -> m r) -> m r) -> ContT r m a
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((a -> m r) -> m r) -> ContT r m a)
-> ((a -> m r) -> m r) -> ContT r m a
forall a b. (a -> b) -> a -> b
$ \a -> m r
c -> SymBool -> m r -> m r -> m r
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf SymBool
cond ((a -> m r) -> m r
l a -> m r
c) ((a -> m r) -> m r
r a -> m r
c)
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a. SymBool -> ContT r m a -> ContT r m a -> ContT r m a
mrgIfPropagatedStrategy SymBool
cond (ContT (a -> m r) -> m r
l) (ContT (a -> m r) -> m r
r) =
((a -> m r) -> m r) -> ContT r m a
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((a -> m r) -> m r) -> ContT r m a)
-> ((a -> m r) -> m r) -> ContT r m a
forall a b. (a -> b) -> a -> b
$ \a -> m r
c -> SymBool -> m r -> m r -> m r
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond ((a -> m r) -> m r
l a -> m r
c) ((a -> m r) -> m r
r a -> m r
c)
{-# INLINE mrgIfPropagatedStrategy #-}
instance
(Mergeable s, Mergeable w, Monoid w, Mergeable a, UnionMergeable1 m) =>
SimpleMergeable (RWSLazy.RWST r w s m a)
where
mrgIte :: SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
mrgIte = SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance
(Mergeable s, Mergeable w, Monoid w, UnionMergeable1 m) =>
SimpleMergeable1 (RWSLazy.RWST r w s m)
where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
forall a.
MergingStrategy a
-> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance
(Mergeable s, Mergeable w, Monoid w, UnionMergeable1 m) =>
UnionMergeable1 (RWSLazy.RWST r w s m)
where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
mrgIfWithStrategy MergingStrategy a
ms SymBool
cond (RWSLazy.RWST r -> s -> m (a, s, w)
t) (RWSLazy.RWST r -> s -> m (a, s, w)
f) =
(r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
RWSLazy.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
MergingStrategy (a, s, w)
-> SymBool -> m (a, s, w) -> m (a, s, w) -> m (a, s, w)
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy
(MergingStrategy a
-> MergingStrategy s
-> MergingStrategy w
-> MergingStrategy (a, s, w)
forall a b c.
MergingStrategy a
-> MergingStrategy b
-> MergingStrategy c
-> MergingStrategy (a, b, c)
forall (u :: * -> * -> * -> *) a b c.
Mergeable3 u =>
MergingStrategy a
-> MergingStrategy b
-> MergingStrategy c
-> MergingStrategy (u a b c)
liftRootStrategy3 MergingStrategy a
ms MergingStrategy s
forall a. Mergeable a => MergingStrategy a
rootStrategy MergingStrategy w
forall a. Mergeable a => MergingStrategy a
rootStrategy)
SymBool
cond
(r -> s -> m (a, s, w)
t r
r s
s)
(r -> s -> m (a, s, w)
f r
r s
s)
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a.
SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
mrgIfPropagatedStrategy SymBool
cond (RWSLazy.RWST r -> s -> m (a, s, w)
t) (RWSLazy.RWST r -> s -> m (a, s, w)
f) =
(r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
RWSLazy.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> SymBool -> m (a, s, w) -> m (a, s, w) -> m (a, s, w)
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond (r -> s -> m (a, s, w)
t r
r s
s) (r -> s -> m (a, s, w)
f r
r s
s)
{-# INLINE mrgIfPropagatedStrategy #-}
instance
(Mergeable s, Mergeable w, Monoid w, Mergeable a, UnionMergeable1 m) =>
SimpleMergeable (RWSStrict.RWST r w s m a)
where
mrgIte :: SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
mrgIte = SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
forall (u :: * -> *) a.
(UnionMergeable1 u, Mergeable a) =>
SymBool -> u a -> u a -> u a
mrgIf
{-# INLINE mrgIte #-}
instance
(Mergeable s, Mergeable w, Monoid w, UnionMergeable1 m) =>
SimpleMergeable1 (RWSStrict.RWST r w s m)
where
liftMrgIte :: forall a.
(SymBool -> a -> a -> a)
-> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
liftMrgIte SymBool -> a -> a -> a
m = MergingStrategy a
-> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
forall a.
MergingStrategy a
-> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy ((SymBool -> a -> a -> a) -> MergingStrategy a
forall a. (SymBool -> a -> a -> a) -> MergingStrategy a
SimpleStrategy SymBool -> a -> a -> a
m)
{-# INLINE liftMrgIte #-}
instance
(Mergeable s, Mergeable w, Monoid w, UnionMergeable1 m) =>
UnionMergeable1 (RWSStrict.RWST r w s m)
where
mrgIfWithStrategy :: forall a.
MergingStrategy a
-> SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
mrgIfWithStrategy MergingStrategy a
ms SymBool
cond (RWSStrict.RWST r -> s -> m (a, s, w)
t) (RWSStrict.RWST r -> s -> m (a, s, w)
f) =
(r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
RWSStrict.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
MergingStrategy (a, s, w)
-> SymBool -> m (a, s, w) -> m (a, s, w) -> m (a, s, w)
forall a. MergingStrategy a -> SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
MergingStrategy a -> SymBool -> u a -> u a -> u a
mrgIfWithStrategy
(MergingStrategy a
-> MergingStrategy s
-> MergingStrategy w
-> MergingStrategy (a, s, w)
forall a b c.
MergingStrategy a
-> MergingStrategy b
-> MergingStrategy c
-> MergingStrategy (a, b, c)
forall (u :: * -> * -> * -> *) a b c.
Mergeable3 u =>
MergingStrategy a
-> MergingStrategy b
-> MergingStrategy c
-> MergingStrategy (u a b c)
liftRootStrategy3 MergingStrategy a
ms MergingStrategy s
forall a. Mergeable a => MergingStrategy a
rootStrategy MergingStrategy w
forall a. Mergeable a => MergingStrategy a
rootStrategy)
SymBool
cond
(r -> s -> m (a, s, w)
t r
r s
s)
(r -> s -> m (a, s, w)
f r
r s
s)
{-# INLINE mrgIfWithStrategy #-}
mrgIfPropagatedStrategy :: forall a.
SymBool -> RWST r w s m a -> RWST r w s m a -> RWST r w s m a
mrgIfPropagatedStrategy SymBool
cond (RWSStrict.RWST r -> s -> m (a, s, w)
t) (RWSStrict.RWST r -> s -> m (a, s, w)
f) =
(r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
RWSStrict.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> SymBool -> m (a, s, w) -> m (a, s, w) -> m (a, s, w)
forall a. SymBool -> m a -> m a -> m a
forall (u :: * -> *) a.
UnionMergeable1 u =>
SymBool -> u a -> u a -> u a
mrgIfPropagatedStrategy SymBool
cond (r -> s -> m (a, s, w)
t r
r s
s) (r -> s -> m (a, s, w)
f r
r s
s)
{-# INLINE mrgIfPropagatedStrategy #-}
#define SIMPLE_MERGEABLE_SIMPLE(symtype) \
instance SimpleMergeable symtype where \
mrgIte = symIte; \
{-# INLINE mrgIte #-}
#define SIMPLE_MERGEABLE_BV(symtype) \
instance (KnownNat n, 1 <= n) => SimpleMergeable (symtype n) where \
mrgIte = symIte; \
{-# INLINE mrgIte #-}
#define SIMPLE_MERGEABLE_FUN(cop, op) \
instance (SupportedPrim (cop ca cb), LinkedRep ca sa, LinkedRep cb sb) => \
SimpleMergeable (op sa sb) where \
mrgIte = symIte; \
{-# INLINE mrgIte #-}
#if 1
SIMPLE_MERGEABLE_SIMPLE(SymBool)
SIMPLE_MERGEABLE_SIMPLE(SymInteger)
SIMPLE_MERGEABLE_BV(SymIntN)
SIMPLE_MERGEABLE_BV(SymWordN)
SIMPLE_MERGEABLE_FUN((=->), (=~>))
SIMPLE_MERGEABLE_FUN((-->), (-~>))
#endif
deriving via (Default AssertionError) instance SimpleMergeable AssertionError