{-# LANGUAGE UndecidableInstances, FlexibleContexts, MultiParamTypeClasses, FlexibleInstances #-}
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ < 710
{-# LANGUAGE Trustworthy #-}
#endif
module Data.Semigroup.Reducer.With
( WithReducer(..)
) where
#if __GLASGOW_HASKELL__ < 710
import Control.Applicative
#endif
import Data.FingerTree
#if __GLASGOW_HASKELL__ < 710
import Data.Foldable
import Data.Traversable
#endif
import Data.Hashable
#if __GLASGOW_HASKELL__ < 710
import Data.Monoid
#endif
import Data.Semigroup.Reducer
import Data.Semigroup.Foldable
import Data.Semigroup.Traversable
import Data.Semigroup.Instances ()
newtype WithReducer m c = WithReducer { forall m c. WithReducer m c -> c
withoutReducer :: c }
deriving (WithReducer m c -> WithReducer m c -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall m c. Eq c => WithReducer m c -> WithReducer m c -> Bool
/= :: WithReducer m c -> WithReducer m c -> Bool
$c/= :: forall m c. Eq c => WithReducer m c -> WithReducer m c -> Bool
== :: WithReducer m c -> WithReducer m c -> Bool
$c== :: forall m c. Eq c => WithReducer m c -> WithReducer m c -> Bool
Eq, WithReducer m c -> WithReducer m c -> Bool
WithReducer m c -> WithReducer m c -> Ordering
WithReducer m c -> WithReducer m c -> WithReducer m c
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 {m} {c}. Ord c => Eq (WithReducer m c)
forall m c. Ord c => WithReducer m c -> WithReducer m c -> Bool
forall m c. Ord c => WithReducer m c -> WithReducer m c -> Ordering
forall m c.
Ord c =>
WithReducer m c -> WithReducer m c -> WithReducer m c
min :: WithReducer m c -> WithReducer m c -> WithReducer m c
$cmin :: forall m c.
Ord c =>
WithReducer m c -> WithReducer m c -> WithReducer m c
max :: WithReducer m c -> WithReducer m c -> WithReducer m c
$cmax :: forall m c.
Ord c =>
WithReducer m c -> WithReducer m c -> WithReducer m c
>= :: WithReducer m c -> WithReducer m c -> Bool
$c>= :: forall m c. Ord c => WithReducer m c -> WithReducer m c -> Bool
> :: WithReducer m c -> WithReducer m c -> Bool
$c> :: forall m c. Ord c => WithReducer m c -> WithReducer m c -> Bool
<= :: WithReducer m c -> WithReducer m c -> Bool
$c<= :: forall m c. Ord c => WithReducer m c -> WithReducer m c -> Bool
< :: WithReducer m c -> WithReducer m c -> Bool
$c< :: forall m c. Ord c => WithReducer m c -> WithReducer m c -> Bool
compare :: WithReducer m c -> WithReducer m c -> Ordering
$ccompare :: forall m c. Ord c => WithReducer m c -> WithReducer m c -> Ordering
Ord, Int -> WithReducer m c -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall m c. Show c => Int -> WithReducer m c -> ShowS
forall m c. Show c => [WithReducer m c] -> ShowS
forall m c. Show c => WithReducer m c -> String
showList :: [WithReducer m c] -> ShowS
$cshowList :: forall m c. Show c => [WithReducer m c] -> ShowS
show :: WithReducer m c -> String
$cshow :: forall m c. Show c => WithReducer m c -> String
showsPrec :: Int -> WithReducer m c -> ShowS
$cshowsPrec :: forall m c. Show c => Int -> WithReducer m c -> ShowS
Show, ReadPrec [WithReducer m c]
ReadPrec (WithReducer m c)
ReadS [WithReducer m c]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall m c. Read c => ReadPrec [WithReducer m c]
forall m c. Read c => ReadPrec (WithReducer m c)
forall m c. Read c => Int -> ReadS (WithReducer m c)
forall m c. Read c => ReadS [WithReducer m c]
readListPrec :: ReadPrec [WithReducer m c]
$creadListPrec :: forall m c. Read c => ReadPrec [WithReducer m c]
readPrec :: ReadPrec (WithReducer m c)
$creadPrec :: forall m c. Read c => ReadPrec (WithReducer m c)
readList :: ReadS [WithReducer m c]
$creadList :: forall m c. Read c => ReadS [WithReducer m c]
readsPrec :: Int -> ReadS (WithReducer m c)
$creadsPrec :: forall m c. Read c => Int -> ReadS (WithReducer m c)
Read)
instance Hashable c => Hashable (WithReducer m c) where
hashWithSalt :: Int -> WithReducer m c -> Int
hashWithSalt Int
n = forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
n forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall m c. WithReducer m c -> c
withoutReducer
instance Functor (WithReducer m) where
fmap :: forall a b. (a -> b) -> WithReducer m a -> WithReducer m b
fmap a -> b
f = forall m c. c -> WithReducer m c
WithReducer forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall m c. WithReducer m c -> c
withoutReducer
instance Foldable (WithReducer m) where
foldMap :: forall m a. Monoid m => (a -> m) -> WithReducer m a -> m
foldMap a -> m
f = a -> m
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall m c. WithReducer m c -> c
withoutReducer
instance Traversable (WithReducer m) where
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WithReducer m a -> f (WithReducer m b)
traverse a -> f b
f (WithReducer a
a) = forall m c. c -> WithReducer m c
WithReducer forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
instance Foldable1 (WithReducer m) where
foldMap1 :: forall m a. Semigroup m => (a -> m) -> WithReducer m a -> m
foldMap1 a -> m
f = a -> m
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall m c. WithReducer m c -> c
withoutReducer
instance Traversable1 (WithReducer m) where
traverse1 :: forall (f :: * -> *) a b.
Apply f =>
(a -> f b) -> WithReducer m a -> f (WithReducer m b)
traverse1 a -> f b
f (WithReducer a
a) = forall m c. c -> WithReducer m c
WithReducer forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
instance Reducer c m => Reducer (WithReducer m c) m where
unit :: WithReducer m c -> m
unit = forall c m. Reducer c m => c -> m
unit forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall m c. WithReducer m c -> c
withoutReducer
instance (Monoid m, Reducer c m) => Measured m (WithReducer m c) where
measure :: WithReducer m c -> m
measure = forall c m. Reducer c m => c -> m
unit forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall m c. WithReducer m c -> c
withoutReducer