{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Data.Monoid.Split
( Split(..)
, split
, unsplit
) where
import Data.Data
import Data.Foldable
import Data.Semigroup
import Data.Traversable
import Data.Monoid.Action
infix 5 :|
data Split m = M m
| m :| m
deriving (Typeable (Split m)
DataType
Constr
Typeable (Split m)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Split m -> c (Split m))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Split m))
-> (Split m -> Constr)
-> (Split m -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Split m)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Split m)))
-> ((forall b. Data b => b -> b) -> Split m -> Split m)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r)
-> (forall u. (forall d. Data d => d -> u) -> Split m -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Split m -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m))
-> Data (Split m)
Split m -> DataType
Split m -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Split m))
(forall b. Data b => b -> b) -> Split m -> Split m
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Split m -> c (Split m)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Split m)
forall m. Data m => Typeable (Split m)
forall m. Data m => Split m -> DataType
forall m. Data m => Split m -> Constr
forall m.
Data m =>
(forall b. Data b => b -> b) -> Split m -> Split m
forall m u.
Data m =>
Int -> (forall d. Data d => d -> u) -> Split m -> u
forall m u.
Data m =>
(forall d. Data d => d -> u) -> Split m -> [u]
forall m r r'.
Data m =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r
forall m r r'.
Data m =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r
forall m (m :: * -> *).
(Data m, Monad m) =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m)
forall m (m :: * -> *).
(Data m, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m)
forall m (c :: * -> *).
Data m =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Split m)
forall m (c :: * -> *).
Data m =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Split m -> c (Split m)
forall m (t :: * -> *) (c :: * -> *).
(Data m, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Split m))
forall m (t :: * -> * -> *) (c :: * -> *).
(Data m, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Split m))
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) -> Split m -> u
forall u. (forall d. Data d => d -> u) -> Split m -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Split m)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Split m -> c (Split m)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Split m))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Split m))
$c:| :: Constr
$cM :: Constr
$tSplit :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Split m -> m (Split m)
$cgmapMo :: forall m (m :: * -> *).
(Data m, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m)
gmapMp :: (forall d. Data d => d -> m d) -> Split m -> m (Split m)
$cgmapMp :: forall m (m :: * -> *).
(Data m, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m)
gmapM :: (forall d. Data d => d -> m d) -> Split m -> m (Split m)
$cgmapM :: forall m (m :: * -> *).
(Data m, Monad m) =>
(forall d. Data d => d -> m d) -> Split m -> m (Split m)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Split m -> u
$cgmapQi :: forall m u.
Data m =>
Int -> (forall d. Data d => d -> u) -> Split m -> u
gmapQ :: (forall d. Data d => d -> u) -> Split m -> [u]
$cgmapQ :: forall m u.
Data m =>
(forall d. Data d => d -> u) -> Split m -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r
$cgmapQr :: forall m r r'.
Data m =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r
$cgmapQl :: forall m r r'.
Data m =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Split m -> r
gmapT :: (forall b. Data b => b -> b) -> Split m -> Split m
$cgmapT :: forall m.
Data m =>
(forall b. Data b => b -> b) -> Split m -> Split m
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Split m))
$cdataCast2 :: forall m (t :: * -> * -> *) (c :: * -> *).
(Data m, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Split m))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Split m))
$cdataCast1 :: forall m (t :: * -> *) (c :: * -> *).
(Data m, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Split m))
dataTypeOf :: Split m -> DataType
$cdataTypeOf :: forall m. Data m => Split m -> DataType
toConstr :: Split m -> Constr
$ctoConstr :: forall m. Data m => Split m -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Split m)
$cgunfold :: forall m (c :: * -> *).
Data m =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Split m)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Split m -> c (Split m)
$cgfoldl :: forall m (c :: * -> *).
Data m =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Split m -> c (Split m)
$cp1Data :: forall m. Data m => Typeable (Split m)
Data, Typeable, Int -> Split m -> ShowS
[Split m] -> ShowS
Split m -> String
(Int -> Split m -> ShowS)
-> (Split m -> String) -> ([Split m] -> ShowS) -> Show (Split m)
forall m. Show m => Int -> Split m -> ShowS
forall m. Show m => [Split m] -> ShowS
forall m. Show m => Split m -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Split m] -> ShowS
$cshowList :: forall m. Show m => [Split m] -> ShowS
show :: Split m -> String
$cshow :: forall m. Show m => Split m -> String
showsPrec :: Int -> Split m -> ShowS
$cshowsPrec :: forall m. Show m => Int -> Split m -> ShowS
Show, ReadPrec [Split m]
ReadPrec (Split m)
Int -> ReadS (Split m)
ReadS [Split m]
(Int -> ReadS (Split m))
-> ReadS [Split m]
-> ReadPrec (Split m)
-> ReadPrec [Split m]
-> Read (Split m)
forall m. Read m => ReadPrec [Split m]
forall m. Read m => ReadPrec (Split m)
forall m. Read m => Int -> ReadS (Split m)
forall m. Read m => ReadS [Split m]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Split m]
$creadListPrec :: forall m. Read m => ReadPrec [Split m]
readPrec :: ReadPrec (Split m)
$creadPrec :: forall m. Read m => ReadPrec (Split m)
readList :: ReadS [Split m]
$creadList :: forall m. Read m => ReadS [Split m]
readsPrec :: Int -> ReadS (Split m)
$creadsPrec :: forall m. Read m => Int -> ReadS (Split m)
Read, Split m -> Split m -> Bool
(Split m -> Split m -> Bool)
-> (Split m -> Split m -> Bool) -> Eq (Split m)
forall m. Eq m => Split m -> Split m -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Split m -> Split m -> Bool
$c/= :: forall m. Eq m => Split m -> Split m -> Bool
== :: Split m -> Split m -> Bool
$c== :: forall m. Eq m => Split m -> Split m -> Bool
Eq, a -> Split b -> Split a
(a -> b) -> Split a -> Split b
(forall a b. (a -> b) -> Split a -> Split b)
-> (forall a b. a -> Split b -> Split a) -> Functor Split
forall a b. a -> Split b -> Split a
forall a b. (a -> b) -> Split a -> Split b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Split b -> Split a
$c<$ :: forall a b. a -> Split b -> Split a
fmap :: (a -> b) -> Split a -> Split b
$cfmap :: forall a b. (a -> b) -> Split a -> Split b
Functor, Split a -> Bool
(a -> m) -> Split a -> m
(a -> b -> b) -> b -> Split a -> b
(forall m. Monoid m => Split m -> m)
-> (forall m a. Monoid m => (a -> m) -> Split a -> m)
-> (forall m a. Monoid m => (a -> m) -> Split a -> m)
-> (forall a b. (a -> b -> b) -> b -> Split a -> b)
-> (forall a b. (a -> b -> b) -> b -> Split a -> b)
-> (forall b a. (b -> a -> b) -> b -> Split a -> b)
-> (forall b a. (b -> a -> b) -> b -> Split a -> b)
-> (forall a. (a -> a -> a) -> Split a -> a)
-> (forall a. (a -> a -> a) -> Split a -> a)
-> (forall a. Split a -> [a])
-> (forall a. Split a -> Bool)
-> (forall a. Split a -> Int)
-> (forall a. Eq a => a -> Split a -> Bool)
-> (forall a. Ord a => Split a -> a)
-> (forall a. Ord a => Split a -> a)
-> (forall a. Num a => Split a -> a)
-> (forall a. Num a => Split a -> a)
-> Foldable Split
forall a. Eq a => a -> Split a -> Bool
forall a. Num a => Split a -> a
forall a. Ord a => Split a -> a
forall m. Monoid m => Split m -> m
forall a. Split a -> Bool
forall a. Split a -> Int
forall a. Split a -> [a]
forall a. (a -> a -> a) -> Split a -> a
forall m a. Monoid m => (a -> m) -> Split a -> m
forall b a. (b -> a -> b) -> b -> Split a -> b
forall a b. (a -> b -> b) -> b -> Split 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
product :: Split a -> a
$cproduct :: forall a. Num a => Split a -> a
sum :: Split a -> a
$csum :: forall a. Num a => Split a -> a
minimum :: Split a -> a
$cminimum :: forall a. Ord a => Split a -> a
maximum :: Split a -> a
$cmaximum :: forall a. Ord a => Split a -> a
elem :: a -> Split a -> Bool
$celem :: forall a. Eq a => a -> Split a -> Bool
length :: Split a -> Int
$clength :: forall a. Split a -> Int
null :: Split a -> Bool
$cnull :: forall a. Split a -> Bool
toList :: Split a -> [a]
$ctoList :: forall a. Split a -> [a]
foldl1 :: (a -> a -> a) -> Split a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Split a -> a
foldr1 :: (a -> a -> a) -> Split a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Split a -> a
foldl' :: (b -> a -> b) -> b -> Split a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Split a -> b
foldl :: (b -> a -> b) -> b -> Split a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Split a -> b
foldr' :: (a -> b -> b) -> b -> Split a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Split a -> b
foldr :: (a -> b -> b) -> b -> Split a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Split a -> b
foldMap' :: (a -> m) -> Split a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Split a -> m
foldMap :: (a -> m) -> Split a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Split a -> m
fold :: Split m -> m
$cfold :: forall m. Monoid m => Split m -> m
Foldable, Functor Split
Foldable Split
Functor Split
-> Foldable Split
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Split a -> f (Split b))
-> (forall (f :: * -> *) a.
Applicative f =>
Split (f a) -> f (Split a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Split a -> m (Split b))
-> (forall (m :: * -> *) a. Monad m => Split (m a) -> m (Split a))
-> Traversable Split
(a -> f b) -> Split a -> f (Split 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 => Split (m a) -> m (Split a)
forall (f :: * -> *) a. Applicative f => Split (f a) -> f (Split a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Split a -> m (Split b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Split a -> f (Split b)
sequence :: Split (m a) -> m (Split a)
$csequence :: forall (m :: * -> *) a. Monad m => Split (m a) -> m (Split a)
mapM :: (a -> m b) -> Split a -> m (Split b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Split a -> m (Split b)
sequenceA :: Split (f a) -> f (Split a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Split (f a) -> f (Split a)
traverse :: (a -> f b) -> Split a -> f (Split b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Split a -> f (Split b)
$cp2Traversable :: Foldable Split
$cp1Traversable :: Functor Split
Traversable)
instance Semigroup m => Semigroup (Split m) where
(M m
m1) <> :: Split m -> Split m -> Split m
<> (M m
m2) = m -> Split m
forall m. m -> Split m
M (m
m1 m -> m -> m
forall a. Semigroup a => a -> a -> a
<> m
m2)
(M m
m1) <> (m
m1' :| m
m2) = m
m1 m -> m -> m
forall a. Semigroup a => a -> a -> a
<> m
m1' m -> m -> Split m
forall m. m -> m -> Split m
:| m
m2
(m
m1 :| m
m2) <> (M m
m2') = m
m1 m -> m -> Split m
forall m. m -> m -> Split m
:| m
m2 m -> m -> m
forall a. Semigroup a => a -> a -> a
<> m
m2'
(m
m11 :| m
m12) <> (m
m21 :| m
m22) = m
m11 m -> m -> m
forall a. Semigroup a => a -> a -> a
<> m
m12 m -> m -> m
forall a. Semigroup a => a -> a -> a
<> m
m21 m -> m -> Split m
forall m. m -> m -> Split m
:| m
m22
instance (Semigroup m, Monoid m) => Monoid (Split m) where
mempty :: Split m
mempty = m -> Split m
forall m. m -> Split m
M m
forall a. Monoid a => a
mempty
mappend :: Split m -> Split m -> Split m
mappend = Split m -> Split m -> Split m
forall a. Semigroup a => a -> a -> a
(<>)
split :: Monoid m => Split m
split :: Split m
split = m
forall a. Monoid a => a
mempty m -> m -> Split m
forall m. m -> m -> Split m
:| m
forall a. Monoid a => a
mempty
unsplit :: Semigroup m => Split m -> m
unsplit :: Split m -> m
unsplit (M m
m) = m
m
unsplit (m
m1 :| m
m2) = m
m1 m -> m -> m
forall a. Semigroup a => a -> a -> a
<> m
m2
instance Action m n => Action (Split m) n where
act :: Split m -> n -> n
act (M m
m) n
n = m -> n -> n
forall m s. Action m s => m -> s -> s
act m
m n
n
act (m
m1 :| m
m2) n
n = m -> n -> n
forall m s. Action m s => m -> s -> s
act m
m1 (m -> n -> n
forall m s. Action m s => m -> s -> s
act m
m2 n
n)