{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Effect.Sum
(
Member(..)
, Members
, (:+:)(..)
, reassociateSumL
) where
import Data.Kind (Constraint, Type)
data (f :+: g) (m :: Type -> Type) k
= L (f m k)
| R (g m k)
deriving ((:+:) f g m k -> (:+:) f g m k -> Bool
((:+:) f g m k -> (:+:) f g m k -> Bool)
-> ((:+:) f g m k -> (:+:) f g m k -> Bool) -> Eq ((:+:) f g m k)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Eq (f m k), Eq (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Bool
/= :: (:+:) f g m k -> (:+:) f g m k -> Bool
$c/= :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Eq (f m k), Eq (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Bool
== :: (:+:) f g m k -> (:+:) f g m k -> Bool
$c== :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Eq (f m k), Eq (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Bool
Eq, (:+:) f g m a -> Bool
(a -> m) -> (:+:) f g m a -> m
(a -> b -> b) -> b -> (:+:) f g m a -> b
(forall m. Monoid m => (:+:) f g m m -> m)
-> (forall m a. Monoid m => (a -> m) -> (:+:) f g m a -> m)
-> (forall m a. Monoid m => (a -> m) -> (:+:) f g m a -> m)
-> (forall a b. (a -> b -> b) -> b -> (:+:) f g m a -> b)
-> (forall a b. (a -> b -> b) -> b -> (:+:) f g m a -> b)
-> (forall b a. (b -> a -> b) -> b -> (:+:) f g m a -> b)
-> (forall b a. (b -> a -> b) -> b -> (:+:) f g m a -> b)
-> (forall a. (a -> a -> a) -> (:+:) f g m a -> a)
-> (forall a. (a -> a -> a) -> (:+:) f g m a -> a)
-> (forall a. (:+:) f g m a -> [a])
-> (forall a. (:+:) f g m a -> Bool)
-> (forall a. (:+:) f g m a -> Int)
-> (forall a. Eq a => a -> (:+:) f g m a -> Bool)
-> (forall a. Ord a => (:+:) f g m a -> a)
-> (forall a. Ord a => (:+:) f g m a -> a)
-> (forall a. Num a => (:+:) f g m a -> a)
-> (forall a. Num a => (:+:) f g m a -> a)
-> Foldable ((:+:) f g m)
forall a. Eq a => a -> (:+:) f g m a -> Bool
forall a. Num a => (:+:) f g m a -> a
forall a. Ord a => (:+:) f g m a -> a
forall m. Monoid m => (:+:) f g m m -> m
forall a. (:+:) f g m a -> Bool
forall a. (:+:) f g m a -> Int
forall a. (:+:) f g m a -> [a]
forall a. (a -> a -> a) -> (:+:) f g m a -> a
forall m a. Monoid m => (a -> m) -> (:+:) f g m a -> m
forall b a. (b -> a -> b) -> b -> (:+:) f g m a -> b
forall a b. (a -> b -> b) -> b -> (:+:) f g m 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
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Eq a) =>
a -> (:+:) f g m a -> Bool
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Num a) =>
(:+:) f g m a -> a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Ord a) =>
(:+:) f g m a -> a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) m.
(Foldable (f m), Foldable (g m), Monoid m) =>
(:+:) f g m m -> m
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(:+:) f g m a -> Bool
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(:+:) f g m a -> Int
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(:+:) f g m a -> [a]
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(a -> a -> a) -> (:+:) f g m a -> a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) m a.
(Foldable (f m), Foldable (g m), Monoid m) =>
(a -> m) -> (:+:) f g m a -> m
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) b a.
(Foldable (f m), Foldable (g m)) =>
(b -> a -> b) -> b -> (:+:) f g m a -> b
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Foldable (f m), Foldable (g m)) =>
(a -> b -> b) -> b -> (:+:) f g m a -> b
product :: (:+:) f g m a -> a
$cproduct :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Num a) =>
(:+:) f g m a -> a
sum :: (:+:) f g m a -> a
$csum :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Num a) =>
(:+:) f g m a -> a
minimum :: (:+:) f g m a -> a
$cminimum :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Ord a) =>
(:+:) f g m a -> a
maximum :: (:+:) f g m a -> a
$cmaximum :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Ord a) =>
(:+:) f g m a -> a
elem :: a -> (:+:) f g m a -> Bool
$celem :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Eq a) =>
a -> (:+:) f g m a -> Bool
length :: (:+:) f g m a -> Int
$clength :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(:+:) f g m a -> Int
null :: (:+:) f g m a -> Bool
$cnull :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(:+:) f g m a -> Bool
toList :: (:+:) f g m a -> [a]
$ctoList :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(:+:) f g m a -> [a]
foldl1 :: (a -> a -> a) -> (:+:) f g m a -> a
$cfoldl1 :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(a -> a -> a) -> (:+:) f g m a -> a
foldr1 :: (a -> a -> a) -> (:+:) f g m a -> a
$cfoldr1 :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(a -> a -> a) -> (:+:) f g m a -> a
foldl' :: (b -> a -> b) -> b -> (:+:) f g m a -> b
$cfoldl' :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) b a.
(Foldable (f m), Foldable (g m)) =>
(b -> a -> b) -> b -> (:+:) f g m a -> b
foldl :: (b -> a -> b) -> b -> (:+:) f g m a -> b
$cfoldl :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) b a.
(Foldable (f m), Foldable (g m)) =>
(b -> a -> b) -> b -> (:+:) f g m a -> b
foldr' :: (a -> b -> b) -> b -> (:+:) f g m a -> b
$cfoldr' :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Foldable (f m), Foldable (g m)) =>
(a -> b -> b) -> b -> (:+:) f g m a -> b
foldr :: (a -> b -> b) -> b -> (:+:) f g m a -> b
$cfoldr :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Foldable (f m), Foldable (g m)) =>
(a -> b -> b) -> b -> (:+:) f g m a -> b
foldMap' :: (a -> m) -> (:+:) f g m a -> m
$cfoldMap' :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) m a.
(Foldable (f m), Foldable (g m), Monoid m) =>
(a -> m) -> (:+:) f g m a -> m
foldMap :: (a -> m) -> (:+:) f g m a -> m
$cfoldMap :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) m a.
(Foldable (f m), Foldable (g m), Monoid m) =>
(a -> m) -> (:+:) f g m a -> m
fold :: (:+:) f g m m -> m
$cfold :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) m.
(Foldable (f m), Foldable (g m), Monoid m) =>
(:+:) f g m m -> m
Foldable, a -> (:+:) f g m b -> (:+:) f g m a
(a -> b) -> (:+:) f g m a -> (:+:) f g m b
(forall a b. (a -> b) -> (:+:) f g m a -> (:+:) f g m b)
-> (forall a b. a -> (:+:) f g m b -> (:+:) f g m a)
-> Functor ((:+:) f g m)
forall a b. a -> (:+:) f g m b -> (:+:) f g m a
forall a b. (a -> b) -> (:+:) f g m a -> (:+:) f g m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Functor (f m), Functor (g m)) =>
a -> (:+:) f g m b -> (:+:) f g m a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Functor (f m), Functor (g m)) =>
(a -> b) -> (:+:) f g m a -> (:+:) f g m b
<$ :: a -> (:+:) f g m b -> (:+:) f g m a
$c<$ :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Functor (f m), Functor (g m)) =>
a -> (:+:) f g m b -> (:+:) f g m a
fmap :: (a -> b) -> (:+:) f g m a -> (:+:) f g m b
$cfmap :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Functor (f m), Functor (g m)) =>
(a -> b) -> (:+:) f g m a -> (:+:) f g m b
Functor, Eq ((:+:) f g m k)
Eq ((:+:) f g m k)
-> ((:+:) f g m k -> (:+:) f g m k -> Ordering)
-> ((:+:) f g m k -> (:+:) f g m k -> Bool)
-> ((:+:) f g m k -> (:+:) f g m k -> Bool)
-> ((:+:) f g m k -> (:+:) f g m k -> Bool)
-> ((:+:) f g m k -> (:+:) f g m k -> Bool)
-> ((:+:) f g m k -> (:+:) f g m k -> (:+:) f g m k)
-> ((:+:) f g m k -> (:+:) f g m k -> (:+:) f g m k)
-> Ord ((:+:) f g m k)
(:+:) f g m k -> (:+:) f g m k -> Bool
(:+:) f g m k -> (:+:) f g m k -> Ordering
(:+:) f g m k -> (:+:) f g m k -> (:+:) f g m k
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
Eq ((:+:) f g m k)
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Bool
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Ordering
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> (:+:) f g m k
min :: (:+:) f g m k -> (:+:) f g m k -> (:+:) f g m k
$cmin :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> (:+:) f g m k
max :: (:+:) f g m k -> (:+:) f g m k -> (:+:) f g m k
$cmax :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> (:+:) f g m k
>= :: (:+:) f g m k -> (:+:) f g m k -> Bool
$c>= :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Bool
> :: (:+:) f g m k -> (:+:) f g m k -> Bool
$c> :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Bool
<= :: (:+:) f g m k -> (:+:) f g m k -> Bool
$c<= :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Bool
< :: (:+:) f g m k -> (:+:) f g m k -> Bool
$c< :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Bool
compare :: (:+:) f g m k -> (:+:) f g m k -> Ordering
$ccompare :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Ordering
$cp1Ord :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
Eq ((:+:) f g m k)
Ord, Int -> (:+:) f g m k -> ShowS
[(:+:) f g m k] -> ShowS
(:+:) f g m k -> String
(Int -> (:+:) f g m k -> ShowS)
-> ((:+:) f g m k -> String)
-> ([(:+:) f g m k] -> ShowS)
-> Show ((:+:) f g m k)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Show (f m k), Show (g m k)) =>
Int -> (:+:) f g m k -> ShowS
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Show (f m k), Show (g m k)) =>
[(:+:) f g m k] -> ShowS
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Show (f m k), Show (g m k)) =>
(:+:) f g m k -> String
showList :: [(:+:) f g m k] -> ShowS
$cshowList :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Show (f m k), Show (g m k)) =>
[(:+:) f g m k] -> ShowS
show :: (:+:) f g m k -> String
$cshow :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Show (f m k), Show (g m k)) =>
(:+:) f g m k -> String
showsPrec :: Int -> (:+:) f g m k -> ShowS
$cshowsPrec :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Show (f m k), Show (g m k)) =>
Int -> (:+:) f g m k -> ShowS
Show, Functor ((:+:) f g m)
Foldable ((:+:) f g m)
Functor ((:+:) f g m)
-> Foldable ((:+:) f g m)
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (:+:) f g m a -> f ((:+:) f g m b))
-> (forall (f :: * -> *) a.
Applicative f =>
(:+:) f g m (f a) -> f ((:+:) f g m a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> (:+:) f g m a -> m ((:+:) f g m b))
-> (forall (m :: * -> *) a.
Monad m =>
(:+:) f g m (m a) -> m ((:+:) f g m a))
-> Traversable ((:+:) f g m)
(a -> f b) -> (:+:) f g m a -> f ((:+:) f g m 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 =>
(:+:) f g m (m a) -> m ((:+:) f g m a)
forall (f :: * -> *) a.
Applicative f =>
(:+:) f g m (f a) -> f ((:+:) f g m a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> (:+:) f g m a -> m ((:+:) f g m b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (:+:) f g m a -> f ((:+:) f g m b)
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *).
(Traversable (f m), Traversable (g m)) =>
Functor ((:+:) f g m)
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *).
(Traversable (f m), Traversable (g m)) =>
Foldable ((:+:) f g m)
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) (m :: * -> *) a.
(Traversable (f m), Traversable (g m), Monad m) =>
(:+:) f g m (m a) -> m ((:+:) f g m a)
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) (f :: * -> *) a.
(Traversable (f m), Traversable (g m), Applicative f) =>
(:+:) f g m (f a) -> f ((:+:) f g m a)
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) (m :: * -> *) a b.
(Traversable (f m), Traversable (g m), Monad m) =>
(a -> m b) -> (:+:) f g m a -> m ((:+:) f g m b)
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) (f :: * -> *) a b.
(Traversable (f m), Traversable (g m), Applicative f) =>
(a -> f b) -> (:+:) f g m a -> f ((:+:) f g m b)
sequence :: (:+:) f g m (m a) -> m ((:+:) f g m a)
$csequence :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) (m :: * -> *) a.
(Traversable (f m), Traversable (g m), Monad m) =>
(:+:) f g m (m a) -> m ((:+:) f g m a)
mapM :: (a -> m b) -> (:+:) f g m a -> m ((:+:) f g m b)
$cmapM :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) (m :: * -> *) a b.
(Traversable (f m), Traversable (g m), Monad m) =>
(a -> m b) -> (:+:) f g m a -> m ((:+:) f g m b)
sequenceA :: (:+:) f g m (f a) -> f ((:+:) f g m a)
$csequenceA :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) (f :: * -> *) a.
(Traversable (f m), Traversable (g m), Applicative f) =>
(:+:) f g m (f a) -> f ((:+:) f g m a)
traverse :: (a -> f b) -> (:+:) f g m a -> f ((:+:) f g m b)
$ctraverse :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) (f :: * -> *) a b.
(Traversable (f m), Traversable (g m), Applicative f) =>
(a -> f b) -> (:+:) f g m a -> f ((:+:) f g m b)
$cp2Traversable :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *).
(Traversable (f m), Traversable (g m)) =>
Foldable ((:+:) f g m)
$cp1Traversable :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *).
(Traversable (f m), Traversable (g m)) =>
Functor ((:+:) f g m)
Traversable)
infixr 4 :+:
class Member (sub :: (Type -> Type) -> (Type -> Type)) sup where
inj :: sub m a -> sup m a
instance Member t t where
inj :: t m a -> t m a
inj = t m a -> t m a
forall a. a -> a
id
{-# INLINE inj #-}
instance {-# OVERLAPPABLE #-}
Member t (l1 :+: l2 :+: r)
=> Member t ((l1 :+: l2) :+: r) where
inj :: t m a -> (:+:) (l1 :+: l2) r m a
inj = (:+:) l1 (l2 :+: r) m a -> (:+:) (l1 :+: l2) r m a
forall (l1 :: (* -> *) -> * -> *) (l2 :: (* -> *) -> * -> *)
(r :: (* -> *) -> * -> *) (m :: * -> *) a.
(:+:) l1 (l2 :+: r) m a -> (:+:) (l1 :+: l2) r m a
reassociateSumL ((:+:) l1 (l2 :+: r) m a -> (:+:) (l1 :+: l2) r m a)
-> (t m a -> (:+:) l1 (l2 :+: r) m a)
-> t m a
-> (:+:) (l1 :+: l2) r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t m a -> (:+:) l1 (l2 :+: r) m a
forall (sub :: (* -> *) -> * -> *) (sup :: (* -> *) -> * -> *)
(m :: * -> *) a.
Member sub sup =>
sub m a -> sup m a
inj
{-# INLINE inj #-}
instance {-# OVERLAPPABLE #-}
Member l (l :+: r) where
inj :: l m a -> (:+:) l r m a
inj = l m a -> (:+:) l r m a
forall (l :: (* -> *) -> * -> *) (r :: (* -> *) -> * -> *)
(m :: * -> *) a.
l m a -> (:+:) l r m a
L
{-# INLINE inj #-}
instance {-# OVERLAPPABLE #-}
Member l r
=> Member l (l' :+: r) where
inj :: l m a -> (:+:) l' r m a
inj = r m a -> (:+:) l' r m a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
g m k -> (:+:) f g m k
R (r m a -> (:+:) l' r m a)
-> (l m a -> r m a) -> l m a -> (:+:) l' r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. l m a -> r m a
forall (sub :: (* -> *) -> * -> *) (sup :: (* -> *) -> * -> *)
(m :: * -> *) a.
Member sub sup =>
sub m a -> sup m a
inj
{-# INLINE inj #-}
reassociateSumL :: (l1 :+: l2 :+: r) m a -> ((l1 :+: l2) :+: r) m a
reassociateSumL :: (:+:) l1 (l2 :+: r) m a -> (:+:) (l1 :+: l2) r m a
reassociateSumL = \case
L l1 m a
l -> (:+:) l1 l2 m a -> (:+:) (l1 :+: l2) r m a
forall (l :: (* -> *) -> * -> *) (r :: (* -> *) -> * -> *)
(m :: * -> *) a.
l m a -> (:+:) l r m a
L (l1 m a -> (:+:) l1 l2 m a
forall (l :: (* -> *) -> * -> *) (r :: (* -> *) -> * -> *)
(m :: * -> *) a.
l m a -> (:+:) l r m a
L l1 m a
l)
R (L l2 m a
l) -> (:+:) l1 l2 m a -> (:+:) (l1 :+: l2) r m a
forall (l :: (* -> *) -> * -> *) (r :: (* -> *) -> * -> *)
(m :: * -> *) a.
l m a -> (:+:) l r m a
L (l2 m a -> (:+:) l1 l2 m a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
g m k -> (:+:) f g m k
R l2 m a
l)
R (R r m a
r) -> r m a -> (:+:) (l1 :+: l2) r m a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
g m k -> (:+:) f g m k
R r m a
r
{-# INLINE reassociateSumL #-}
type family Members sub sup :: Constraint where
Members (l :+: r) u = (Members l u, Members r u)
Members t u = Member t u