{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Distribution.Types.CondTree
( CondTree (..)
, CondBranch (..)
, condIfThen
, condIfThenElse
, foldCondTree
, mapCondTree
, mapTreeConds
, mapTreeData
, traverseCondTreeA
, traverseCondTreeV
, traverseCondBranchA
, traverseCondBranchV
, extractCondition
, simplifyCondTree
, simplifyCondBranch
, ignoreConditions
) where
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Types.Condition
import qualified Distribution.Compat.Lens as L
data CondTree v a = CondNode
{ forall v a. CondTree v a -> a
condTreeData :: a
, forall v a. CondTree v a -> [CondBranch v a]
condTreeComponents :: [CondBranch v a]
}
deriving (Int -> CondTree v a -> ShowS
[CondTree v a] -> ShowS
CondTree v a -> String
(Int -> CondTree v a -> ShowS)
-> (CondTree v a -> String)
-> ([CondTree v a] -> ShowS)
-> Show (CondTree v a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall v a. (Show a, Show v) => Int -> CondTree v a -> ShowS
forall v a. (Show a, Show v) => [CondTree v a] -> ShowS
forall v a. (Show a, Show v) => CondTree v a -> String
$cshowsPrec :: forall v a. (Show a, Show v) => Int -> CondTree v a -> ShowS
showsPrec :: Int -> CondTree v a -> ShowS
$cshow :: forall v a. (Show a, Show v) => CondTree v a -> String
show :: CondTree v a -> String
$cshowList :: forall v a. (Show a, Show v) => [CondTree v a] -> ShowS
showList :: [CondTree v a] -> ShowS
Show, CondTree v a -> CondTree v a -> Bool
(CondTree v a -> CondTree v a -> Bool)
-> (CondTree v a -> CondTree v a -> Bool) -> Eq (CondTree v a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall v a. (Eq a, Eq v) => CondTree v a -> CondTree v a -> Bool
$c== :: forall v a. (Eq a, Eq v) => CondTree v a -> CondTree v a -> Bool
== :: CondTree v a -> CondTree v a -> Bool
$c/= :: forall v a. (Eq a, Eq v) => CondTree v a -> CondTree v a -> Bool
/= :: CondTree v a -> CondTree v a -> Bool
Eq, Typeable (CondTree v a)
Typeable (CondTree v a) =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondTree v a -> c (CondTree v a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondTree v a))
-> (CondTree v a -> Constr)
-> (CondTree v a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CondTree v a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondTree v a)))
-> ((forall b. Data b => b -> b) -> CondTree v a -> CondTree v a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r)
-> (forall u. (forall d. Data d => d -> u) -> CondTree v a -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> CondTree v a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a))
-> Data (CondTree v a)
CondTree v a -> Constr
CondTree v a -> DataType
(forall b. Data b => b -> b) -> CondTree v a -> CondTree v a
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> CondTree v a -> u
forall u. (forall d. Data d => d -> u) -> CondTree v a -> [u]
forall v a. (Data v, Data a) => Typeable (CondTree v a)
forall v a. (Data v, Data a) => CondTree v a -> Constr
forall v a. (Data v, Data a) => CondTree v a -> DataType
forall v a.
(Data v, Data a) =>
(forall b. Data b => b -> b) -> CondTree v a -> CondTree v a
forall v a u.
(Data v, Data a) =>
Int -> (forall d. Data d => d -> u) -> CondTree v a -> u
forall v a u.
(Data v, Data a) =>
(forall d. Data d => d -> u) -> CondTree v a -> [u]
forall v a r r'.
(Data v, Data a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r
forall v a r r'.
(Data v, Data a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r
forall v a (m :: * -> *).
(Data v, Data a, Monad m) =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
forall v a (m :: * -> *).
(Data v, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
forall v a (c :: * -> *).
(Data v, Data a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondTree v a)
forall v a (c :: * -> *).
(Data v, Data a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondTree v a -> c (CondTree v a)
forall v a (t :: * -> *) (c :: * -> *).
(Data v, Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (CondTree v a))
forall v a (t :: * -> * -> *) (c :: * -> *).
(Data v, Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondTree v a))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondTree v a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondTree v a -> c (CondTree v a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CondTree v a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondTree v a))
$cgfoldl :: forall v a (c :: * -> *).
(Data v, Data a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondTree v a -> c (CondTree v a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondTree v a -> c (CondTree v a)
$cgunfold :: forall v a (c :: * -> *).
(Data v, Data a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondTree v a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondTree v a)
$ctoConstr :: forall v a. (Data v, Data a) => CondTree v a -> Constr
toConstr :: CondTree v a -> Constr
$cdataTypeOf :: forall v a. (Data v, Data a) => CondTree v a -> DataType
dataTypeOf :: CondTree v a -> DataType
$cdataCast1 :: forall v a (t :: * -> *) (c :: * -> *).
(Data v, Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (CondTree v a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CondTree v a))
$cdataCast2 :: forall v a (t :: * -> * -> *) (c :: * -> *).
(Data v, Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondTree v a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondTree v a))
$cgmapT :: forall v a.
(Data v, Data a) =>
(forall b. Data b => b -> b) -> CondTree v a -> CondTree v a
gmapT :: (forall b. Data b => b -> b) -> CondTree v a -> CondTree v a
$cgmapQl :: forall v a r r'.
(Data v, Data a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r
$cgmapQr :: forall v a r r'.
(Data v, Data a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondTree v a -> r
$cgmapQ :: forall v a u.
(Data v, Data a) =>
(forall d. Data d => d -> u) -> CondTree v a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> CondTree v a -> [u]
$cgmapQi :: forall v a u.
(Data v, Data a) =>
Int -> (forall d. Data d => d -> u) -> CondTree v a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CondTree v a -> u
$cgmapM :: forall v a (m :: * -> *).
(Data v, Data a, Monad m) =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
$cgmapMp :: forall v a (m :: * -> *).
(Data v, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
$cgmapMo :: forall v a (m :: * -> *).
(Data v, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CondTree v a -> m (CondTree v a)
Data, (forall x. CondTree v a -> Rep (CondTree v a) x)
-> (forall x. Rep (CondTree v a) x -> CondTree v a)
-> Generic (CondTree v a)
forall x. Rep (CondTree v a) x -> CondTree v a
forall x. CondTree v a -> Rep (CondTree v a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall v a x. Rep (CondTree v a) x -> CondTree v a
forall v a x. CondTree v a -> Rep (CondTree v a) x
$cfrom :: forall v a x. CondTree v a -> Rep (CondTree v a) x
from :: forall x. CondTree v a -> Rep (CondTree v a) x
$cto :: forall v a x. Rep (CondTree v a) x -> CondTree v a
to :: forall x. Rep (CondTree v a) x -> CondTree v a
Generic, (forall a b. (a -> b) -> CondTree v a -> CondTree v b)
-> (forall a b. a -> CondTree v b -> CondTree v a)
-> Functor (CondTree v)
forall a b. a -> CondTree v b -> CondTree v a
forall a b. (a -> b) -> CondTree v a -> CondTree v b
forall v a b. a -> CondTree v b -> CondTree v a
forall v a b. (a -> b) -> CondTree v a -> CondTree v b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall v a b. (a -> b) -> CondTree v a -> CondTree v b
fmap :: forall a b. (a -> b) -> CondTree v a -> CondTree v b
$c<$ :: forall v a b. a -> CondTree v b -> CondTree v a
<$ :: forall a b. a -> CondTree v b -> CondTree v a
Functor, (forall m. Monoid m => CondTree v m -> m)
-> (forall m a. Monoid m => (a -> m) -> CondTree v a -> m)
-> (forall m a. Monoid m => (a -> m) -> CondTree v a -> m)
-> (forall a b. (a -> b -> b) -> b -> CondTree v a -> b)
-> (forall a b. (a -> b -> b) -> b -> CondTree v a -> b)
-> (forall b a. (b -> a -> b) -> b -> CondTree v a -> b)
-> (forall b a. (b -> a -> b) -> b -> CondTree v a -> b)
-> (forall a. (a -> a -> a) -> CondTree v a -> a)
-> (forall a. (a -> a -> a) -> CondTree v a -> a)
-> (forall a. CondTree v a -> [a])
-> (forall a. CondTree v a -> Bool)
-> (forall a. CondTree v a -> Int)
-> (forall a. Eq a => a -> CondTree v a -> Bool)
-> (forall a. Ord a => CondTree v a -> a)
-> (forall a. Ord a => CondTree v a -> a)
-> (forall a. Num a => CondTree v a -> a)
-> (forall a. Num a => CondTree v a -> a)
-> Foldable (CondTree v)
forall a. Eq a => a -> CondTree v a -> Bool
forall a. Num a => CondTree v a -> a
forall a. Ord a => CondTree v a -> a
forall m. Monoid m => CondTree v m -> m
forall a. CondTree v a -> Bool
forall a. CondTree v a -> Int
forall a. CondTree v a -> [a]
forall a. (a -> a -> a) -> CondTree v a -> a
forall v a. Eq a => a -> CondTree v a -> Bool
forall v a. Num a => CondTree v a -> a
forall v a. Ord a => CondTree v a -> a
forall v m. Monoid m => CondTree v m -> m
forall m a. Monoid m => (a -> m) -> CondTree v a -> m
forall v a. CondTree v a -> Bool
forall v a. CondTree v a -> Int
forall v a. CondTree v a -> [a]
forall b a. (b -> a -> b) -> b -> CondTree v a -> b
forall a b. (a -> b -> b) -> b -> CondTree v a -> b
forall v a. (a -> a -> a) -> CondTree v a -> a
forall v m a. Monoid m => (a -> m) -> CondTree v a -> m
forall v b a. (b -> a -> b) -> b -> CondTree v a -> b
forall v a b. (a -> b -> b) -> b -> CondTree v a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall v m. Monoid m => CondTree v m -> m
fold :: forall m. Monoid m => CondTree v m -> m
$cfoldMap :: forall v m a. Monoid m => (a -> m) -> CondTree v a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> CondTree v a -> m
$cfoldMap' :: forall v m a. Monoid m => (a -> m) -> CondTree v a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> CondTree v a -> m
$cfoldr :: forall v a b. (a -> b -> b) -> b -> CondTree v a -> b
foldr :: forall a b. (a -> b -> b) -> b -> CondTree v a -> b
$cfoldr' :: forall v a b. (a -> b -> b) -> b -> CondTree v a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> CondTree v a -> b
$cfoldl :: forall v b a. (b -> a -> b) -> b -> CondTree v a -> b
foldl :: forall b a. (b -> a -> b) -> b -> CondTree v a -> b
$cfoldl' :: forall v b a. (b -> a -> b) -> b -> CondTree v a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> CondTree v a -> b
$cfoldr1 :: forall v a. (a -> a -> a) -> CondTree v a -> a
foldr1 :: forall a. (a -> a -> a) -> CondTree v a -> a
$cfoldl1 :: forall v a. (a -> a -> a) -> CondTree v a -> a
foldl1 :: forall a. (a -> a -> a) -> CondTree v a -> a
$ctoList :: forall v a. CondTree v a -> [a]
toList :: forall a. CondTree v a -> [a]
$cnull :: forall v a. CondTree v a -> Bool
null :: forall a. CondTree v a -> Bool
$clength :: forall v a. CondTree v a -> Int
length :: forall a. CondTree v a -> Int
$celem :: forall v a. Eq a => a -> CondTree v a -> Bool
elem :: forall a. Eq a => a -> CondTree v a -> Bool
$cmaximum :: forall v a. Ord a => CondTree v a -> a
maximum :: forall a. Ord a => CondTree v a -> a
$cminimum :: forall v a. Ord a => CondTree v a -> a
minimum :: forall a. Ord a => CondTree v a -> a
$csum :: forall v a. Num a => CondTree v a -> a
sum :: forall a. Num a => CondTree v a -> a
$cproduct :: forall v a. Num a => CondTree v a -> a
product :: forall a. Num a => CondTree v a -> a
Foldable, Functor (CondTree v)
Foldable (CondTree v)
(Functor (CondTree v), Foldable (CondTree v)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondTree v a -> f (CondTree v b))
-> (forall (f :: * -> *) a.
Applicative f =>
CondTree v (f a) -> f (CondTree v a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondTree v a -> m (CondTree v b))
-> (forall (m :: * -> *) a.
Monad m =>
CondTree v (m a) -> m (CondTree v a))
-> Traversable (CondTree v)
forall v. Functor (CondTree v)
forall v. Foldable (CondTree v)
forall v (m :: * -> *) a.
Monad m =>
CondTree v (m a) -> m (CondTree v a)
forall v (f :: * -> *) a.
Applicative f =>
CondTree v (f a) -> f (CondTree v a)
forall v (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondTree v a -> m (CondTree v b)
forall v (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondTree v a -> f (CondTree v b)
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
CondTree v (m a) -> m (CondTree v a)
forall (f :: * -> *) a.
Applicative f =>
CondTree v (f a) -> f (CondTree v a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondTree v a -> m (CondTree v b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondTree v a -> f (CondTree v b)
$ctraverse :: forall v (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondTree v a -> f (CondTree v b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondTree v a -> f (CondTree v b)
$csequenceA :: forall v (f :: * -> *) a.
Applicative f =>
CondTree v (f a) -> f (CondTree v a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
CondTree v (f a) -> f (CondTree v a)
$cmapM :: forall v (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondTree v a -> m (CondTree v b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondTree v a -> m (CondTree v b)
$csequence :: forall v (m :: * -> *) a.
Monad m =>
CondTree v (m a) -> m (CondTree v a)
sequence :: forall (m :: * -> *) a.
Monad m =>
CondTree v (m a) -> m (CondTree v a)
Traversable)
instance (Binary v, Binary a) => Binary (CondTree v a)
instance (Structured v, Structured a) => Structured (CondTree v a)
instance (NFData v, NFData a) => NFData (CondTree v a)
instance Semigroup a => Semigroup (CondTree v a) where
(CondNode a
a [CondBranch v a]
bs) <> :: CondTree v a -> CondTree v a -> CondTree v a
<> (CondNode a
a' [CondBranch v a]
bs') = a -> [CondBranch v a] -> CondTree v a
forall v a. a -> [CondBranch v a] -> CondTree v a
CondNode (a
a a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
a') ([CondBranch v a]
bs [CondBranch v a] -> [CondBranch v a] -> [CondBranch v a]
forall a. Semigroup a => a -> a -> a
<> [CondBranch v a]
bs')
instance Monoid a => Monoid (CondTree v a) where
mappend :: CondTree v a -> CondTree v a -> CondTree v a
mappend = CondTree v a -> CondTree v a -> CondTree v a
forall a. Semigroup a => a -> a -> a
(<>)
mempty :: CondTree v a
mempty = a -> [CondBranch v a] -> CondTree v a
forall v a. a -> [CondBranch v a] -> CondTree v a
CondNode a
forall a. Monoid a => a
mempty [CondBranch v a]
forall a. Monoid a => a
mempty
data CondBranch v a = CondBranch
{ forall v a. CondBranch v a -> Condition v
condBranchCondition :: Condition v
, forall v a. CondBranch v a -> CondTree v a
condBranchIfTrue :: CondTree v a
, forall v a. CondBranch v a -> Maybe (CondTree v a)
condBranchIfFalse :: Maybe (CondTree v a)
}
deriving (Int -> CondBranch v a -> ShowS
[CondBranch v a] -> ShowS
CondBranch v a -> String
(Int -> CondBranch v a -> ShowS)
-> (CondBranch v a -> String)
-> ([CondBranch v a] -> ShowS)
-> Show (CondBranch v a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall v a. (Show v, Show a) => Int -> CondBranch v a -> ShowS
forall v a. (Show v, Show a) => [CondBranch v a] -> ShowS
forall v a. (Show v, Show a) => CondBranch v a -> String
$cshowsPrec :: forall v a. (Show v, Show a) => Int -> CondBranch v a -> ShowS
showsPrec :: Int -> CondBranch v a -> ShowS
$cshow :: forall v a. (Show v, Show a) => CondBranch v a -> String
show :: CondBranch v a -> String
$cshowList :: forall v a. (Show v, Show a) => [CondBranch v a] -> ShowS
showList :: [CondBranch v a] -> ShowS
Show, CondBranch v a -> CondBranch v a -> Bool
(CondBranch v a -> CondBranch v a -> Bool)
-> (CondBranch v a -> CondBranch v a -> Bool)
-> Eq (CondBranch v a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall v a.
(Eq v, Eq a) =>
CondBranch v a -> CondBranch v a -> Bool
$c== :: forall v a.
(Eq v, Eq a) =>
CondBranch v a -> CondBranch v a -> Bool
== :: CondBranch v a -> CondBranch v a -> Bool
$c/= :: forall v a.
(Eq v, Eq a) =>
CondBranch v a -> CondBranch v a -> Bool
/= :: CondBranch v a -> CondBranch v a -> Bool
Eq, Typeable (CondBranch v a)
Typeable (CondBranch v a) =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondBranch v a -> c (CondBranch v a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondBranch v a))
-> (CondBranch v a -> Constr)
-> (CondBranch v a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CondBranch v a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondBranch v a)))
-> ((forall b. Data b => b -> b)
-> CondBranch v a -> CondBranch v a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r)
-> (forall u.
(forall d. Data d => d -> u) -> CondBranch v a -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> CondBranch v a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a))
-> Data (CondBranch v a)
CondBranch v a -> Constr
CondBranch v a -> DataType
(forall b. Data b => b -> b) -> CondBranch v a -> CondBranch v a
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> CondBranch v a -> u
forall u. (forall d. Data d => d -> u) -> CondBranch v a -> [u]
forall v a. (Data v, Data a) => Typeable (CondBranch v a)
forall v a. (Data v, Data a) => CondBranch v a -> Constr
forall v a. (Data v, Data a) => CondBranch v a -> DataType
forall v a.
(Data v, Data a) =>
(forall b. Data b => b -> b) -> CondBranch v a -> CondBranch v a
forall v a u.
(Data v, Data a) =>
Int -> (forall d. Data d => d -> u) -> CondBranch v a -> u
forall v a u.
(Data v, Data a) =>
(forall d. Data d => d -> u) -> CondBranch v a -> [u]
forall v a r r'.
(Data v, Data a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r
forall v a r r'.
(Data v, Data a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r
forall v a (m :: * -> *).
(Data v, Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
forall v a (m :: * -> *).
(Data v, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
forall v a (c :: * -> *).
(Data v, Data a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondBranch v a)
forall v a (c :: * -> *).
(Data v, Data a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondBranch v a -> c (CondBranch v a)
forall v a (t :: * -> *) (c :: * -> *).
(Data v, Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (CondBranch v a))
forall v a (t :: * -> * -> *) (c :: * -> *).
(Data v, Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondBranch v a))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondBranch v a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondBranch v a -> c (CondBranch v a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CondBranch v a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondBranch v a))
$cgfoldl :: forall v a (c :: * -> *).
(Data v, Data a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondBranch v a -> c (CondBranch v a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CondBranch v a -> c (CondBranch v a)
$cgunfold :: forall v a (c :: * -> *).
(Data v, Data a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondBranch v a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (CondBranch v a)
$ctoConstr :: forall v a. (Data v, Data a) => CondBranch v a -> Constr
toConstr :: CondBranch v a -> Constr
$cdataTypeOf :: forall v a. (Data v, Data a) => CondBranch v a -> DataType
dataTypeOf :: CondBranch v a -> DataType
$cdataCast1 :: forall v a (t :: * -> *) (c :: * -> *).
(Data v, Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (CondBranch v a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (CondBranch v a))
$cdataCast2 :: forall v a (t :: * -> * -> *) (c :: * -> *).
(Data v, Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondBranch v a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (CondBranch v a))
$cgmapT :: forall v a.
(Data v, Data a) =>
(forall b. Data b => b -> b) -> CondBranch v a -> CondBranch v a
gmapT :: (forall b. Data b => b -> b) -> CondBranch v a -> CondBranch v a
$cgmapQl :: forall v a r r'.
(Data v, Data a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r
$cgmapQr :: forall v a r r'.
(Data v, Data a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CondBranch v a -> r
$cgmapQ :: forall v a u.
(Data v, Data a) =>
(forall d. Data d => d -> u) -> CondBranch v a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> CondBranch v a -> [u]
$cgmapQi :: forall v a u.
(Data v, Data a) =>
Int -> (forall d. Data d => d -> u) -> CondBranch v a -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CondBranch v a -> u
$cgmapM :: forall v a (m :: * -> *).
(Data v, Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
$cgmapMp :: forall v a (m :: * -> *).
(Data v, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
$cgmapMo :: forall v a (m :: * -> *).
(Data v, Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CondBranch v a -> m (CondBranch v a)
Data, (forall x. CondBranch v a -> Rep (CondBranch v a) x)
-> (forall x. Rep (CondBranch v a) x -> CondBranch v a)
-> Generic (CondBranch v a)
forall x. Rep (CondBranch v a) x -> CondBranch v a
forall x. CondBranch v a -> Rep (CondBranch v a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall v a x. Rep (CondBranch v a) x -> CondBranch v a
forall v a x. CondBranch v a -> Rep (CondBranch v a) x
$cfrom :: forall v a x. CondBranch v a -> Rep (CondBranch v a) x
from :: forall x. CondBranch v a -> Rep (CondBranch v a) x
$cto :: forall v a x. Rep (CondBranch v a) x -> CondBranch v a
to :: forall x. Rep (CondBranch v a) x -> CondBranch v a
Generic, (forall a b. (a -> b) -> CondBranch v a -> CondBranch v b)
-> (forall a b. a -> CondBranch v b -> CondBranch v a)
-> Functor (CondBranch v)
forall a b. a -> CondBranch v b -> CondBranch v a
forall a b. (a -> b) -> CondBranch v a -> CondBranch v b
forall v a b. a -> CondBranch v b -> CondBranch v a
forall v a b. (a -> b) -> CondBranch v a -> CondBranch v b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall v a b. (a -> b) -> CondBranch v a -> CondBranch v b
fmap :: forall a b. (a -> b) -> CondBranch v a -> CondBranch v b
$c<$ :: forall v a b. a -> CondBranch v b -> CondBranch v a
<$ :: forall a b. a -> CondBranch v b -> CondBranch v a
Functor, Functor (CondBranch v)
Foldable (CondBranch v)
(Functor (CondBranch v), Foldable (CondBranch v)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondBranch v a -> f (CondBranch v b))
-> (forall (f :: * -> *) a.
Applicative f =>
CondBranch v (f a) -> f (CondBranch v a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondBranch v a -> m (CondBranch v b))
-> (forall (m :: * -> *) a.
Monad m =>
CondBranch v (m a) -> m (CondBranch v a))
-> Traversable (CondBranch v)
forall v. Functor (CondBranch v)
forall v. Foldable (CondBranch v)
forall v (m :: * -> *) a.
Monad m =>
CondBranch v (m a) -> m (CondBranch v a)
forall v (f :: * -> *) a.
Applicative f =>
CondBranch v (f a) -> f (CondBranch v a)
forall v (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondBranch v a -> m (CondBranch v b)
forall v (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondBranch v a -> f (CondBranch v b)
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
CondBranch v (m a) -> m (CondBranch v a)
forall (f :: * -> *) a.
Applicative f =>
CondBranch v (f a) -> f (CondBranch v a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondBranch v a -> m (CondBranch v b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondBranch v a -> f (CondBranch v b)
$ctraverse :: forall v (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondBranch v a -> f (CondBranch v b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> CondBranch v a -> f (CondBranch v b)
$csequenceA :: forall v (f :: * -> *) a.
Applicative f =>
CondBranch v (f a) -> f (CondBranch v a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
CondBranch v (f a) -> f (CondBranch v a)
$cmapM :: forall v (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondBranch v a -> m (CondBranch v b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> CondBranch v a -> m (CondBranch v b)
$csequence :: forall v (m :: * -> *) a.
Monad m =>
CondBranch v (m a) -> m (CondBranch v a)
sequence :: forall (m :: * -> *) a.
Monad m =>
CondBranch v (m a) -> m (CondBranch v a)
Traversable, (forall m. Monoid m => CondBranch v m -> m)
-> (forall m a. Monoid m => (a -> m) -> CondBranch v a -> m)
-> (forall m a. Monoid m => (a -> m) -> CondBranch v a -> m)
-> (forall a b. (a -> b -> b) -> b -> CondBranch v a -> b)
-> (forall a b. (a -> b -> b) -> b -> CondBranch v a -> b)
-> (forall b a. (b -> a -> b) -> b -> CondBranch v a -> b)
-> (forall b a. (b -> a -> b) -> b -> CondBranch v a -> b)
-> (forall a. (a -> a -> a) -> CondBranch v a -> a)
-> (forall a. (a -> a -> a) -> CondBranch v a -> a)
-> (forall a. CondBranch v a -> [a])
-> (forall a. CondBranch v a -> Bool)
-> (forall a. CondBranch v a -> Int)
-> (forall a. Eq a => a -> CondBranch v a -> Bool)
-> (forall a. Ord a => CondBranch v a -> a)
-> (forall a. Ord a => CondBranch v a -> a)
-> (forall a. Num a => CondBranch v a -> a)
-> (forall a. Num a => CondBranch v a -> a)
-> Foldable (CondBranch v)
forall a. Eq a => a -> CondBranch v a -> Bool
forall a. Num a => CondBranch v a -> a
forall a. Ord a => CondBranch v a -> a
forall m. Monoid m => CondBranch v m -> m
forall a. CondBranch v a -> Bool
forall a. CondBranch v a -> Int
forall a. CondBranch v a -> [a]
forall a. (a -> a -> a) -> CondBranch v a -> a
forall v a. Eq a => a -> CondBranch v a -> Bool
forall v a. Num a => CondBranch v a -> a
forall v a. Ord a => CondBranch v a -> a
forall v m. Monoid m => CondBranch v m -> m
forall m a. Monoid m => (a -> m) -> CondBranch v a -> m
forall v a. CondBranch v a -> Bool
forall v a. CondBranch v a -> Int
forall v a. CondBranch v a -> [a]
forall b a. (b -> a -> b) -> b -> CondBranch v a -> b
forall a b. (a -> b -> b) -> b -> CondBranch v a -> b
forall v a. (a -> a -> a) -> CondBranch v a -> a
forall v m a. Monoid m => (a -> m) -> CondBranch v a -> m
forall v b a. (b -> a -> b) -> b -> CondBranch v a -> b
forall v a b. (a -> b -> b) -> b -> CondBranch v a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall v m. Monoid m => CondBranch v m -> m
fold :: forall m. Monoid m => CondBranch v m -> m
$cfoldMap :: forall v m a. Monoid m => (a -> m) -> CondBranch v a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> CondBranch v a -> m
$cfoldMap' :: forall v m a. Monoid m => (a -> m) -> CondBranch v a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> CondBranch v a -> m
$cfoldr :: forall v a b. (a -> b -> b) -> b -> CondBranch v a -> b
foldr :: forall a b. (a -> b -> b) -> b -> CondBranch v a -> b
$cfoldr' :: forall v a b. (a -> b -> b) -> b -> CondBranch v a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> CondBranch v a -> b
$cfoldl :: forall v b a. (b -> a -> b) -> b -> CondBranch v a -> b
foldl :: forall b a. (b -> a -> b) -> b -> CondBranch v a -> b
$cfoldl' :: forall v b a. (b -> a -> b) -> b -> CondBranch v a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> CondBranch v a -> b
$cfoldr1 :: forall v a. (a -> a -> a) -> CondBranch v a -> a
foldr1 :: forall a. (a -> a -> a) -> CondBranch v a -> a
$cfoldl1 :: forall v a. (a -> a -> a) -> CondBranch v a -> a
foldl1 :: forall a. (a -> a -> a) -> CondBranch v a -> a
$ctoList :: forall v a. CondBranch v a -> [a]
toList :: forall a. CondBranch v a -> [a]
$cnull :: forall v a. CondBranch v a -> Bool
null :: forall a. CondBranch v a -> Bool
$clength :: forall v a. CondBranch v a -> Int
length :: forall a. CondBranch v a -> Int
$celem :: forall v a. Eq a => a -> CondBranch v a -> Bool
elem :: forall a. Eq a => a -> CondBranch v a -> Bool
$cmaximum :: forall v a. Ord a => CondBranch v a -> a
maximum :: forall a. Ord a => CondBranch v a -> a
$cminimum :: forall v a. Ord a => CondBranch v a -> a
minimum :: forall a. Ord a => CondBranch v a -> a
$csum :: forall v a. Num a => CondBranch v a -> a
sum :: forall a. Num a => CondBranch v a -> a
$cproduct :: forall v a. Num a => CondBranch v a -> a
product :: forall a. Num a => CondBranch v a -> a
Foldable)
instance (Binary v, Binary a) => Binary (CondBranch v a)
instance (Structured v, Structured a) => Structured (CondBranch v a)
instance (NFData v, NFData a) => NFData (CondBranch v a)
condIfThen :: Condition v -> CondTree v a -> CondBranch v a
condIfThen :: forall v a. Condition v -> CondTree v a -> CondBranch v a
condIfThen Condition v
c CondTree v a
t = Condition v
-> CondTree v a -> Maybe (CondTree v a) -> CondBranch v a
forall v a.
Condition v
-> CondTree v a -> Maybe (CondTree v a) -> CondBranch v a
CondBranch Condition v
c CondTree v a
t Maybe (CondTree v a)
forall a. Maybe a
Nothing
condIfThenElse :: Condition v -> CondTree v a -> CondTree v a -> CondBranch v a
condIfThenElse :: forall v a.
Condition v -> CondTree v a -> CondTree v a -> CondBranch v a
condIfThenElse Condition v
c CondTree v a
t CondTree v a
e = Condition v
-> CondTree v a -> Maybe (CondTree v a) -> CondBranch v a
forall v a.
Condition v
-> CondTree v a -> Maybe (CondTree v a) -> CondBranch v a
CondBranch Condition v
c CondTree v a
t (CondTree v a -> Maybe (CondTree v a)
forall a. a -> Maybe a
Just CondTree v a
e)
mapCondTree
:: (a -> b)
-> (Condition v -> Condition w)
-> CondTree v a
-> CondTree w b
mapCondTree :: forall a b v w.
(a -> b)
-> (Condition v -> Condition w) -> CondTree v a -> CondTree w b
mapCondTree a -> b
fa Condition v -> Condition w
fcnd (CondNode a
a [CondBranch v a]
ifs) =
b -> [CondBranch w b] -> CondTree w b
forall v a. a -> [CondBranch v a] -> CondTree v a
CondNode (a -> b
fa a
a) ((CondBranch v a -> CondBranch w b)
-> [CondBranch v a] -> [CondBranch w b]
forall a b. (a -> b) -> [a] -> [b]
map CondBranch v a -> CondBranch w b
g [CondBranch v a]
ifs)
where
g :: CondBranch v a -> CondBranch w b
g (CondBranch Condition v
cnd CondTree v a
t Maybe (CondTree v a)
me) =
Condition w
-> CondTree w b -> Maybe (CondTree w b) -> CondBranch w b
forall v a.
Condition v
-> CondTree v a -> Maybe (CondTree v a) -> CondBranch v a
CondBranch
(Condition v -> Condition w
fcnd Condition v
cnd)
((a -> b)
-> (Condition v -> Condition w) -> CondTree v a -> CondTree w b
forall a b v w.
(a -> b)
-> (Condition v -> Condition w) -> CondTree v a -> CondTree w b
mapCondTree a -> b
fa Condition v -> Condition w
fcnd CondTree v a
t)
((CondTree v a -> CondTree w b)
-> Maybe (CondTree v a) -> Maybe (CondTree w b)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b)
-> (Condition v -> Condition w) -> CondTree v a -> CondTree w b
forall a b v w.
(a -> b)
-> (Condition v -> Condition w) -> CondTree v a -> CondTree w b
mapCondTree a -> b
fa Condition v -> Condition w
fcnd) Maybe (CondTree v a)
me)
mapTreeConds :: (Condition v -> Condition w) -> CondTree v a -> CondTree w a
mapTreeConds :: forall v w a.
(Condition v -> Condition w) -> CondTree v a -> CondTree w a
mapTreeConds Condition v -> Condition w
f = (a -> a)
-> (Condition v -> Condition w) -> CondTree v a -> CondTree w a
forall a b v w.
(a -> b)
-> (Condition v -> Condition w) -> CondTree v a -> CondTree w b
mapCondTree a -> a
forall a. a -> a
id Condition v -> Condition w
f
mapTreeData :: (a -> b) -> CondTree v a -> CondTree v b
mapTreeData :: forall a b v. (a -> b) -> CondTree v a -> CondTree v b
mapTreeData a -> b
f = (a -> b)
-> (Condition v -> Condition v) -> CondTree v a -> CondTree v b
forall a b v w.
(a -> b)
-> (Condition v -> Condition w) -> CondTree v a -> CondTree w b
mapCondTree a -> b
f Condition v -> Condition v
forall a. a -> a
id
traverseCondTreeA :: L.Traversal (CondTree v a) (CondTree v b) a b
traverseCondTreeA :: forall v a b (f :: * -> *).
Applicative f =>
LensLike f (CondTree v a) (CondTree v b) a b
traverseCondTreeA a -> f b
f (CondNode a
a [CondBranch v a]
ifs) =
b -> [CondBranch v b] -> CondTree v b
forall v a. a -> [CondBranch v a] -> CondTree v a
CondNode
(b -> [CondBranch v b] -> CondTree v b)
-> f b -> f ([CondBranch v b] -> CondTree v b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
f ([CondBranch v b] -> CondTree v b)
-> f [CondBranch v b] -> f (CondTree v b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (CondBranch v a -> f (CondBranch v b))
-> [CondBranch v a] -> f [CondBranch v b]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (LensLike f (CondBranch v a) (CondBranch v b) a b
forall v a b (f :: * -> *).
Applicative f =>
LensLike f (CondBranch v a) (CondBranch v b) a b
traverseCondBranchA a -> f b
f) [CondBranch v a]
ifs
traverseCondTreeV :: L.Traversal (CondTree v a) (CondTree w a) v w
traverseCondTreeV :: forall v a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v a) (CondTree w a) v w
traverseCondTreeV v -> f w
f (CondNode a
a [CondBranch v a]
ifs) =
a -> [CondBranch w a] -> CondTree w a
forall v a. a -> [CondBranch v a] -> CondTree v a
CondNode a
a ([CondBranch w a] -> CondTree w a)
-> f [CondBranch w a] -> f (CondTree w a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (CondBranch v a -> f (CondBranch w a))
-> [CondBranch v a] -> f [CondBranch w a]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (LensLike f (CondBranch v a) (CondBranch w a) v w
forall v a w (f :: * -> *).
Applicative f =>
LensLike f (CondBranch v a) (CondBranch w a) v w
traverseCondBranchV v -> f w
f) [CondBranch v a]
ifs
traverseCondBranchA :: L.Traversal (CondBranch v a) (CondBranch v b) a b
traverseCondBranchA :: forall v a b (f :: * -> *).
Applicative f =>
LensLike f (CondBranch v a) (CondBranch v b) a b
traverseCondBranchA a -> f b
f (CondBranch Condition v
cnd CondTree v a
t Maybe (CondTree v a)
me) =
(CondTree v b -> Maybe (CondTree v b) -> CondBranch v b)
-> f (CondTree v b -> Maybe (CondTree v b) -> CondBranch v b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Condition v
-> CondTree v b -> Maybe (CondTree v b) -> CondBranch v b
forall v a.
Condition v
-> CondTree v a -> Maybe (CondTree v a) -> CondBranch v a
CondBranch Condition v
cnd)
f (CondTree v b -> Maybe (CondTree v b) -> CondBranch v b)
-> f (CondTree v b) -> f (Maybe (CondTree v b) -> CondBranch v b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LensLike f (CondTree v a) (CondTree v b) a b
forall v a b (f :: * -> *).
Applicative f =>
LensLike f (CondTree v a) (CondTree v b) a b
traverseCondTreeA a -> f b
f CondTree v a
t
f (Maybe (CondTree v b) -> CondBranch v b)
-> f (Maybe (CondTree v b)) -> f (CondBranch v b)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (CondTree v a -> f (CondTree v b))
-> Maybe (CondTree v a) -> f (Maybe (CondTree v b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse (LensLike f (CondTree v a) (CondTree v b) a b
forall v a b (f :: * -> *).
Applicative f =>
LensLike f (CondTree v a) (CondTree v b) a b
traverseCondTreeA a -> f b
f) Maybe (CondTree v a)
me
traverseCondBranchV :: L.Traversal (CondBranch v a) (CondBranch w a) v w
traverseCondBranchV :: forall v a w (f :: * -> *).
Applicative f =>
LensLike f (CondBranch v a) (CondBranch w a) v w
traverseCondBranchV v -> f w
f (CondBranch Condition v
cnd CondTree v a
t Maybe (CondTree v a)
me) =
Condition w
-> CondTree w a -> Maybe (CondTree w a) -> CondBranch w a
forall v a.
Condition v
-> CondTree v a -> Maybe (CondTree v a) -> CondBranch v a
CondBranch
(Condition w
-> CondTree w a -> Maybe (CondTree w a) -> CondBranch w a)
-> f (Condition w)
-> f (CondTree w a -> Maybe (CondTree w a) -> CondBranch w a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (v -> f w) -> Condition v -> f (Condition w)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Condition a -> f (Condition b)
traverse v -> f w
f Condition v
cnd
f (CondTree w a -> Maybe (CondTree w a) -> CondBranch w a)
-> f (CondTree w a) -> f (Maybe (CondTree w a) -> CondBranch w a)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LensLike f (CondTree v a) (CondTree w a) v w
forall v a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v a) (CondTree w a) v w
traverseCondTreeV v -> f w
f CondTree v a
t
f (Maybe (CondTree w a) -> CondBranch w a)
-> f (Maybe (CondTree w a)) -> f (CondBranch w a)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (CondTree v a -> f (CondTree w a))
-> Maybe (CondTree v a) -> f (Maybe (CondTree w a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse (LensLike f (CondTree v a) (CondTree w a) v w
forall v a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v a) (CondTree w a) v w
traverseCondTreeV v -> f w
f) Maybe (CondTree v a)
me
extractCondition :: Eq v => (a -> Bool) -> CondTree v a -> Condition v
a -> Bool
p = CondTree v a -> Condition v
forall {c}. Eq c => CondTree c a -> Condition c
go
where
go :: CondTree c a -> Condition c
go (CondNode a
x [CondBranch c a]
cs)
| Bool -> Bool
not (a -> Bool
p a
x) = Bool -> Condition c
forall c. Bool -> Condition c
Lit Bool
False
| Bool
otherwise = [CondBranch c a] -> Condition c
goList [CondBranch c a]
cs
goList :: [CondBranch c a] -> Condition c
goList [] = Bool -> Condition c
forall c. Bool -> Condition c
Lit Bool
True
goList (CondBranch Condition c
c CondTree c a
t Maybe (CondTree c a)
e : [CondBranch c a]
cs) =
let
ct :: Condition c
ct = CondTree c a -> Condition c
go CondTree c a
t
ce :: Condition c
ce = Condition c
-> (CondTree c a -> Condition c)
-> Maybe (CondTree c a)
-> Condition c
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Bool -> Condition c
forall c. Bool -> Condition c
Lit Bool
True) CondTree c a -> Condition c
go Maybe (CondTree c a)
e
in
((Condition c
c Condition c -> Condition c -> Condition c
forall a. Condition a -> Condition a -> Condition a
`cAnd` Condition c
ct) Condition c -> Condition c -> Condition c
forall v. Eq v => Condition v -> Condition v -> Condition v
`cOr` (Condition c -> Condition c
forall c. Condition c -> Condition c
CNot Condition c
c Condition c -> Condition c -> Condition c
forall a. Condition a -> Condition a -> Condition a
`cAnd` Condition c
ce)) Condition c -> Condition c -> Condition c
forall a. Condition a -> Condition a -> Condition a
`cAnd` [CondBranch c a] -> Condition c
goList [CondBranch c a]
cs
simplifyCondTree
:: Semigroup a
=> (v -> Either v Bool)
-> CondTree v a
-> a
simplifyCondTree :: forall a v.
Semigroup a =>
(v -> Either v Bool) -> CondTree v a -> a
simplifyCondTree v -> Either v Bool
env (CondNode a
a [CondBranch v a]
ifs) =
(a -> a -> a) -> a -> [a] -> a
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl a -> a -> a
forall a. Semigroup a => a -> a -> a
(<>) a
a ([a] -> a) -> [a] -> a
forall a b. (a -> b) -> a -> b
$ (CondBranch v a -> Maybe a) -> [CondBranch v a] -> [a]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe ((v -> Either v Bool) -> CondBranch v a -> Maybe a
forall a v.
Semigroup a =>
(v -> Either v Bool) -> CondBranch v a -> Maybe a
simplifyCondBranch v -> Either v Bool
env) [CondBranch v a]
ifs
simplifyCondBranch
:: Semigroup a
=> (v -> Either v Bool)
-> CondBranch v a
-> Maybe a
simplifyCondBranch :: forall a v.
Semigroup a =>
(v -> Either v Bool) -> CondBranch v a -> Maybe a
simplifyCondBranch v -> Either v Bool
env (CondBranch Condition v
cnd CondTree v a
t Maybe (CondTree v a)
me) =
case Condition v -> (v -> Either v Bool) -> (Condition v, [v])
forall c d.
Condition c -> (c -> Either d Bool) -> (Condition d, [d])
simplifyCondition Condition v
cnd v -> Either v Bool
env of
(Lit Bool
True, [v]
_) -> a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$ (v -> Either v Bool) -> CondTree v a -> a
forall a v.
Semigroup a =>
(v -> Either v Bool) -> CondTree v a -> a
simplifyCondTree v -> Either v Bool
env CondTree v a
t
(Lit Bool
False, [v]
_) -> (CondTree v a -> a) -> Maybe (CondTree v a) -> Maybe a
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((v -> Either v Bool) -> CondTree v a -> a
forall a v.
Semigroup a =>
(v -> Either v Bool) -> CondTree v a -> a
simplifyCondTree v -> Either v Bool
env) Maybe (CondTree v a)
me
(Condition v, [v])
_ -> Maybe a
forall a. Maybe a
Nothing
ignoreConditions :: Semigroup a => CondTree v a -> a
ignoreConditions :: forall a v. Semigroup a => CondTree v a -> a
ignoreConditions (CondNode a
a [CondBranch v a]
ifs) = (a -> a -> a) -> a -> [a] -> a
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl a -> a -> a
forall a. Semigroup a => a -> a -> a
(<>) a
a ([a] -> a) -> [a] -> a
forall a b. (a -> b) -> a -> b
$ (CondBranch v a -> [a]) -> [CondBranch v a] -> [a]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap CondBranch v a -> [a]
forall {a} {v}. Semigroup a => CondBranch v a -> [a]
f [CondBranch v a]
ifs
where
f :: CondBranch v a -> [a]
f (CondBranch Condition v
_ CondTree v a
t Maybe (CondTree v a)
me) =
CondTree v a -> a
forall a v. Semigroup a => CondTree v a -> a
ignoreConditions CondTree v a
t
a -> [a] -> [a]
forall a. a -> [a] -> [a]
: Maybe a -> [a]
forall a. Maybe a -> [a]
maybeToList ((CondTree v a -> a) -> Maybe (CondTree v a) -> Maybe a
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CondTree v a -> a
forall a v. Semigroup a => CondTree v a -> a
ignoreConditions Maybe (CondTree v a)
me)
foldCondTree :: forall b a v. b -> (a -> b) -> (b -> b -> b) -> (b -> b -> b) -> CondTree v a -> b
foldCondTree :: forall b a v.
b
-> (a -> b) -> (b -> b -> b) -> (b -> b -> b) -> CondTree v a -> b
foldCondTree b
e a -> b
u b -> b -> b
mergeInclusive b -> b -> b
mergeExclusive = CondTree v a -> b
goTree
where
goTree :: CondTree v a -> b
goTree :: CondTree v a -> b
goTree (CondNode a
a [CondBranch v a]
ifs) = a -> b
u a
a b -> b -> b
`mergeInclusive` (b -> CondBranch v a -> b) -> b -> [CondBranch v a] -> b
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl b -> CondBranch v a -> b
goBranch b
e [CondBranch v a]
ifs
goBranch :: b -> CondBranch v a -> b
goBranch :: b -> CondBranch v a -> b
goBranch b
acc (CondBranch Condition v
_ CondTree v a
t Maybe (CondTree v a)
mt) = b -> b -> b
mergeInclusive b
acc (b -> (CondTree v a -> b) -> Maybe (CondTree v a) -> b
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (CondTree v a -> b
goTree CondTree v a
t) (b -> b -> b
mergeExclusive (CondTree v a -> b
goTree CondTree v a
t) (b -> b) -> (CondTree v a -> b) -> CondTree v a -> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CondTree v a -> b
goTree) Maybe (CondTree v a)
mt)