{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StrictData #-}
module Data.Tuple.Strict.T3
( T3 (..),
)
where
import Control.DeepSeq (NFData, rnf)
import Data.Bifoldable
import Data.Bifunctor
import Data.Bitraversable
import Data.Functor.Classes (Eq1 (liftEq), Eq2 (liftEq2))
import Data.Hashable (Hashable, hash, hashWithSalt)
import Data.Hashable.Lifted
( Hashable1,
Hashable2,
defaultLiftHashWithSalt,
hashWithSalt1,
liftHashWithSalt,
liftHashWithSalt2,
)
import Data.Semigroup
import GHC.Generics (Generic)
data T3 a b c
= T3 a b c
deriving stock (T3 a b c
forall a. a -> a -> Bounded a
forall a b c. (Bounded a, Bounded b, Bounded c) => T3 a b c
maxBound :: T3 a b c
$cmaxBound :: forall a b c. (Bounded a, Bounded b, Bounded c) => T3 a b c
minBound :: T3 a b c
$cminBound :: forall a b c. (Bounded a, Bounded b, Bounded c) => T3 a b c
Bounded, T3 a b c -> T3 a b c -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall a b c. (Eq a, Eq b, Eq c) => T3 a b c -> T3 a b c -> Bool
/= :: T3 a b c -> T3 a b c -> Bool
$c/= :: forall a b c. (Eq a, Eq b, Eq c) => T3 a b c -> T3 a b c -> Bool
== :: T3 a b c -> T3 a b c -> Bool
$c== :: forall a b c. (Eq a, Eq b, Eq c) => T3 a b c -> T3 a b c -> Bool
Eq, T3 a b c -> T3 a b c -> Bool
T3 a b c -> T3 a b c -> Ordering
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 {a} {b} {c}. (Ord a, Ord b, Ord c) => Eq (T3 a b c)
forall a b c. (Ord a, Ord b, Ord c) => T3 a b c -> T3 a b c -> Bool
forall a b c.
(Ord a, Ord b, Ord c) =>
T3 a b c -> T3 a b c -> Ordering
forall a b c.
(Ord a, Ord b, Ord c) =>
T3 a b c -> T3 a b c -> T3 a b c
min :: T3 a b c -> T3 a b c -> T3 a b c
$cmin :: forall a b c.
(Ord a, Ord b, Ord c) =>
T3 a b c -> T3 a b c -> T3 a b c
max :: T3 a b c -> T3 a b c -> T3 a b c
$cmax :: forall a b c.
(Ord a, Ord b, Ord c) =>
T3 a b c -> T3 a b c -> T3 a b c
>= :: T3 a b c -> T3 a b c -> Bool
$c>= :: forall a b c. (Ord a, Ord b, Ord c) => T3 a b c -> T3 a b c -> Bool
> :: T3 a b c -> T3 a b c -> Bool
$c> :: forall a b c. (Ord a, Ord b, Ord c) => T3 a b c -> T3 a b c -> Bool
<= :: T3 a b c -> T3 a b c -> Bool
$c<= :: forall a b c. (Ord a, Ord b, Ord c) => T3 a b c -> T3 a b c -> Bool
< :: T3 a b c -> T3 a b c -> Bool
$c< :: forall a b c. (Ord a, Ord b, Ord c) => T3 a b c -> T3 a b c -> Bool
compare :: T3 a b c -> T3 a b c -> Ordering
$ccompare :: forall a b c.
(Ord a, Ord b, Ord c) =>
T3 a b c -> T3 a b c -> Ordering
Ord, ReadPrec [T3 a b c]
ReadPrec (T3 a b c)
ReadS [T3 a b c]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall a b c. (Read a, Read b, Read c) => ReadPrec [T3 a b c]
forall a b c. (Read a, Read b, Read c) => ReadPrec (T3 a b c)
forall a b c. (Read a, Read b, Read c) => Int -> ReadS (T3 a b c)
forall a b c. (Read a, Read b, Read c) => ReadS [T3 a b c]
readListPrec :: ReadPrec [T3 a b c]
$creadListPrec :: forall a b c. (Read a, Read b, Read c) => ReadPrec [T3 a b c]
readPrec :: ReadPrec (T3 a b c)
$creadPrec :: forall a b c. (Read a, Read b, Read c) => ReadPrec (T3 a b c)
readList :: ReadS [T3 a b c]
$creadList :: forall a b c. (Read a, Read b, Read c) => ReadS [T3 a b c]
readsPrec :: Int -> ReadS (T3 a b c)
$creadsPrec :: forall a b c. (Read a, Read b, Read c) => Int -> ReadS (T3 a b c)
Read, Int -> T3 a b c -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b c. (Show a, Show b, Show c) => Int -> T3 a b c -> ShowS
forall a b c. (Show a, Show b, Show c) => [T3 a b c] -> ShowS
forall a b c. (Show a, Show b, Show c) => T3 a b c -> String
showList :: [T3 a b c] -> ShowS
$cshowList :: forall a b c. (Show a, Show b, Show c) => [T3 a b c] -> ShowS
show :: T3 a b c -> String
$cshow :: forall a b c. (Show a, Show b, Show c) => T3 a b c -> String
showsPrec :: Int -> T3 a b c -> ShowS
$cshowsPrec :: forall a b c. (Show a, Show b, Show c) => Int -> T3 a b c -> ShowS
Show, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a b c x. Rep (T3 a b c) x -> T3 a b c
forall a b c x. T3 a b c -> Rep (T3 a b c) x
$cto :: forall a b c x. Rep (T3 a b c) x -> T3 a b c
$cfrom :: forall a b c x. T3 a b c -> Rep (T3 a b c) x
Generic)
deriving stock instance Foldable (T3 a b)
deriving stock instance Functor (T3 a b)
deriving stock instance Traversable (T3 a b)
instance (Eq a, Eq b) => Eq1 (T3 a b) where
liftEq :: forall a b. (a -> b -> Bool) -> T3 a b a -> T3 a b b -> Bool
liftEq = forall (f :: * -> * -> *) a b c d.
Eq2 f =>
(a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
liftEq2 forall a. Eq a => a -> a -> Bool
(==)
instance Eq a => Eq2 (T3 a) where
liftEq2 :: forall a b c d.
(a -> b -> Bool)
-> (c -> d -> Bool) -> T3 a a c -> T3 a b d -> Bool
liftEq2 a -> b -> Bool
e1 c -> d -> Bool
e2 (T3 a
a a
b c
c ) (T3 a
a' b
b' d
c') =
a
a forall a. Eq a => a -> a -> Bool
== a
a' Bool -> Bool -> Bool
&& a -> b -> Bool
e1 a
b b
b' Bool -> Bool -> Bool
&& c -> d -> Bool
e2 c
c d
c'
instance (Monoid a, Monoid b) => Applicative (T3 a b) where
pure :: forall a. a -> T3 a b a
pure a
c = forall a b c. a -> b -> c -> T3 a b c
T3 forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty a
c
T3 a
a b
b a -> b
f <*> :: forall a b. T3 a b (a -> b) -> T3 a b a -> T3 a b b
<*> T3 a
a' b
b' a
c = forall a b c. a -> b -> c -> T3 a b c
T3 (a
a forall a. Semigroup a => a -> a -> a
<> a
a') (b
b forall a. Semigroup a => a -> a -> a
<> b
b') (a -> b
f a
c)
instance (Monoid a, Monoid b) => Monad (T3 a b) where
return :: forall a. a -> T3 a b a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
T3 a
a b
b a
c >>= :: forall a b. T3 a b a -> (a -> T3 a b b) -> T3 a b b
>>= a -> T3 a b b
f = case a -> T3 a b b
f a
c of
T3 a
a' b
b' b
c' -> forall a b c. a -> b -> c -> T3 a b c
T3 (a
a forall a. Semigroup a => a -> a -> a
<> a
a') (b
b forall a. Semigroup a => a -> a -> a
<> b
b') b
c'
instance (Hashable a, Hashable b, Hashable c) => Hashable (T3 a b c) where
hash :: T3 a b c -> Int
hash (T3 a
a b
b c
c) = forall a. Hashable a => a -> Int
hash a
a forall a. Hashable a => Int -> a -> Int
`hashWithSalt` b
b forall a. Hashable a => Int -> a -> Int
`hashWithSalt` c
c
hashWithSalt :: Int -> T3 a b c -> Int
hashWithSalt = forall (f :: * -> *) a.
(Hashable1 f, Hashable a) =>
Int -> f a -> Int
hashWithSalt1
instance (Hashable a, Hashable b) => Hashable1 (T3 a b) where
liftHashWithSalt :: forall a. (Int -> a -> Int) -> Int -> T3 a b a -> Int
liftHashWithSalt = forall (f :: * -> * -> *) a b.
(Hashable2 f, Hashable a) =>
(Int -> b -> Int) -> Int -> f a b -> Int
defaultLiftHashWithSalt
instance Hashable a => Hashable2 (T3 a) where
liftHashWithSalt2 :: forall a b.
(Int -> a -> Int) -> (Int -> b -> Int) -> Int -> T3 a a b -> Int
liftHashWithSalt2 Int -> a -> Int
h1 Int -> b -> Int
h2 Int
slt (T3 a
a a
b b
c) =
(Int
slt forall a. Hashable a => Int -> a -> Int
`hashWithSalt` a
a) Int -> a -> Int
`h1` a
b Int -> b -> Int
`h2` b
c
instance (Monoid a, Monoid b, Monoid c) => Monoid (T3 a b c) where
mempty :: T3 a b c
mempty = forall a b c. a -> b -> c -> T3 a b c
T3 forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty
instance (NFData a, NFData b, NFData c) => NFData (T3 a b c) where
rnf :: T3 a b c -> ()
rnf (T3 a
a b
b c
c) = forall a. NFData a => a -> ()
rnf a
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf b
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf c
c
instance (Semigroup a, Semigroup b, Semigroup c) => Semigroup (T3 a b c) where
T3 a
a1 b
b1 c
c1 <> :: T3 a b c -> T3 a b c -> T3 a b c
<> T3 a
a2 b
b2 c
c2 = forall a b c. a -> b -> c -> T3 a b c
T3 (a
a1 forall a. Semigroup a => a -> a -> a
<> a
a2) (b
b1 forall a. Semigroup a => a -> a -> a
<> b
b2) (c
c1 forall a. Semigroup a => a -> a -> a
<> c
c2)
stimes :: forall b. Integral b => b -> T3 a b c -> T3 a b c
stimes b
ii (T3 a
a b
b c
c) = forall a b c. a -> b -> c -> T3 a b c
T3 (forall a b. (Semigroup a, Integral b) => b -> a -> a
stimes b
ii a
a) (forall a b. (Semigroup a, Integral b) => b -> a -> a
stimes b
ii b
b) (forall a b. (Semigroup a, Integral b) => b -> a -> a
stimes b
ii c
c)
instance Bifunctor (T3 x) where
bimap :: forall a b c d. (a -> b) -> (c -> d) -> T3 x a c -> T3 x b d
bimap a -> b
f c -> d
g (T3 x
x a
a c
b) = forall a b c. a -> b -> c -> T3 a b c
T3 x
x (a -> b
f a
a) (c -> d
g c
b)
instance Bifoldable (T3 x) where
bifoldMap :: forall m a b. Monoid m => (a -> m) -> (b -> m) -> T3 x a b -> m
bifoldMap a -> m
f b -> m
g (T3 x
_ a
a b
b) = a -> m
f a
a forall a. Semigroup a => a -> a -> a
<> b -> m
g b
b
instance Bitraversable (T3 x) where
bitraverse :: forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> T3 x a b -> f (T3 x c d)
bitraverse a -> f c
f b -> f d
g (T3 x
x a
a b
b) = forall a b c. a -> b -> c -> T3 a b c
T3 x
x forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f c
f a
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> b -> f d
g b
b