{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# 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
$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
/= :: (:+:) f g m k -> (:+:) f g m k -> Bool
Eq, (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
$cfold :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) m.
(Foldable (f m), Foldable (g m), Monoid m) =>
(:+:) f g m m -> m
fold :: forall m. Monoid m => (:+:) f g m m -> m
$cfoldMap :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) m a.
(Foldable (f m), Foldable (g m), Monoid m) =>
(a -> m) -> (:+:) f g m a -> m
foldMap :: forall m a. Monoid m => (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' :: forall m a. Monoid m => (a -> m) -> (:+:) f g m a -> m
$cfoldr :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Foldable (f m), Foldable (g m)) =>
(a -> b -> b) -> b -> (:+:) f g m a -> b
foldr :: forall a b. (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' :: forall a b. (a -> b -> 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 :: forall b a. (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' :: forall b a. (b -> a -> b) -> b -> (:+:) f g m a -> b
$cfoldr1 :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(a -> a -> a) -> (:+:) f g m a -> a
foldr1 :: forall a. (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
foldl1 :: forall a. (a -> a -> a) -> (:+:) f g m a -> a
$ctoList :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(:+:) f g m a -> [a]
toList :: forall a. (:+:) f g m a -> [a]
$cnull :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(:+:) f g m a -> Bool
null :: forall a. (:+:) f g m a -> Bool
$clength :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m)) =>
(:+:) f g m a -> Int
length :: forall a. (:+:) f g m a -> Int
$celem :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Eq a) =>
a -> (:+:) f g m a -> Bool
elem :: forall a. Eq a => a -> (:+:) f g m a -> Bool
$cmaximum :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Ord a) =>
(:+:) f g m a -> a
maximum :: forall a. Ord a => (:+:) f g m a -> a
$cminimum :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Ord a) =>
(:+:) f g m a -> a
minimum :: forall a. Ord a => (:+:) f g m a -> a
$csum :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Num a) =>
(:+:) f g m a -> a
sum :: forall a. Num a => (:+:) f g m a -> a
$cproduct :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a.
(Foldable (f m), Foldable (g m), Num a) =>
(:+:) f g m a -> a
product :: forall a. Num a => (:+:) f g m a -> a
Foldable, (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
$cfmap :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Functor (f m), Functor (g m)) =>
(a -> b) -> (:+:) f g m a -> (:+:) f g m b
fmap :: forall a b. (a -> b) -> (:+:) f g m a -> (:+:) f g m b
$c<$ :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) a b.
(Functor (f m), Functor (g m)) =>
a -> (:+:) f g m b -> (:+:) f g m a
<$ :: forall a b. a -> (:+:) f g m b -> (:+:) f g m a
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
$ccompare :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Ord (f m k), Ord (g m k)) =>
(:+:) f g m k -> (:+:) f g m k -> Ordering
compare :: (:+:) f g m k -> (:+:) f g m k -> Ordering
$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
>= :: (:+:) f g m k -> (:+:) f g m k -> Bool
$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
max :: (:+:) 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
min :: (:+:) f g m k -> (:+:) f g m k -> (:+:) 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
$cshowsPrec :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Show (f m k), Show (g m k)) =>
Int -> (:+:) f g m k -> ShowS
showsPrec :: Int -> (:+:) f g m k -> ShowS
$cshow :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Show (f m k), Show (g m k)) =>
(:+:) f g m k -> String
show :: (:+:) f g m k -> String
$cshowList :: forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
(Show (f m k), Show (g m k)) =>
[(:+:) f g m k] -> ShowS
showList :: [(:+:) 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)
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)
$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)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (:+:) f g m a -> f ((:+:) f g m b)
$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)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
(:+:) f g m (f a) -> f ((:+:) f g m a)
$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)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> (:+:) f g m a -> m ((:+:) f g m b)
$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)
sequence :: forall (m :: * -> *) a.
Monad m =>
(:+:) f g m (m a) -> m ((:+:) f g m a)
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 :: forall (m :: * -> *) a. 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 :: forall (m :: * -> *) a. 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 (m :: * -> *) a. 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 :: forall (m :: * -> *) a. 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 :: forall (m :: * -> *) a. 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 (m :: * -> *) a. 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 :: forall (l1 :: (* -> *) -> * -> *) (l2 :: (* -> *) -> * -> *)
(r :: (* -> *) -> * -> *) (m :: * -> *) a.
(:+:) 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