module Algebra.OrderDecision where
import qualified Algebra.EqualityDecision as Equality
import Algebra.EqualityDecision ((==?), )
import qualified NumericPrelude.Elementwise as Elem
import Control.Applicative (Applicative(pure, (<*>)), )
import Data.Tuple.HT (fst3, snd3, thd3, )
import Data.List (zipWith4, zipWith5, )
import Prelude hiding (compare, min, max, minimum, maximum, )
import qualified Prelude as P
class Equality.C a => C a where
compare :: a -> a -> a -> a -> a -> a
compare a
x a
y a
lt a
eq a
gt =
(a
x a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
==? a
y) a
eq ((a
x a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
<=? a
y) a
lt a
gt)
{-# INLINE (<=?) #-}
(<=?) :: a -> a -> a -> a -> a
(<=?) a
x a
y a
le a
gt =
a -> a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a -> a
compare a
x a
y a
le a
le a
gt
{-# INLINE (>=?) #-}
(>=?) :: a -> a -> a -> a -> a
(>=?) = (a -> a -> a -> a -> a) -> a -> a -> a -> a -> a
forall a b c. (a -> b -> c) -> b -> a -> c
flip a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
(<=?)
(<?) :: a -> a -> a -> a -> a
(<?) a
x a
y = (a -> a -> a) -> a -> a -> a
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a
x a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
>=? a
y)
{-# INLINE (>?) #-}
(>?) :: a -> a -> a -> a -> a
(>?) = (a -> a -> a -> a -> a) -> a -> a -> a -> a -> a
forall a b c. (a -> b -> c) -> b -> a -> c
flip a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
(<?)
max :: C a => a -> a -> a
max :: a -> a -> a
max a
x a
y = (a
xa -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
>?a
y) a
x a
y
min :: C a => a -> a -> a
min :: a -> a -> a
min a
x a
y = (a
xa -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
<?a
y) a
x a
y
maximum :: C a => a -> [a] -> a
maximum :: a -> [a] -> a
maximum a
x [a]
xs = (a -> a -> a) -> a -> [a] -> a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl a -> a -> a
forall a. C a => a -> a -> a
max a
x [a]
xs
minimum :: C a => a -> [a] -> a
minimum :: a -> [a] -> a
minimum a
x [a]
xs = (a -> a -> a) -> a -> [a] -> a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl a -> a -> a
forall a. C a => a -> a -> a
min a
x [a]
xs
{-# INLINE compareOrd #-}
compareOrd :: Ord a => a -> a -> a -> a -> a -> a
compareOrd :: a -> a -> a -> a -> a -> a
compareOrd a
a a
b a
lt a
eq a
gt =
case a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
P.compare a
a a
b of
Ordering
LT -> a
lt
Ordering
EQ -> a
eq
Ordering
GT -> a
gt
instance C Int where
{-# INLINE compare #-}
compare :: Int -> Int -> Int -> Int -> Int -> Int
compare = Int -> Int -> Int -> Int -> Int -> Int
forall a. Ord a => a -> a -> a -> a -> a -> a
compareOrd
instance C Integer where
{-# INLINE compare #-}
compare :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer
compare = Integer -> Integer -> Integer -> Integer -> Integer -> Integer
forall a. Ord a => a -> a -> a -> a -> a -> a
compareOrd
instance C Float where
{-# INLINE compare #-}
compare :: Float -> Float -> Float -> Float -> Float -> Float
compare = Float -> Float -> Float -> Float -> Float -> Float
forall a. Ord a => a -> a -> a -> a -> a -> a
compareOrd
instance C Double where
{-# INLINE compare #-}
compare :: Double -> Double -> Double -> Double -> Double -> Double
compare = Double -> Double -> Double -> Double -> Double -> Double
forall a. Ord a => a -> a -> a -> a -> a -> a
compareOrd
instance C Bool where
{-# INLINE compare #-}
compare :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool
compare = Bool -> Bool -> Bool -> Bool -> Bool -> Bool
forall a. Ord a => a -> a -> a -> a -> a -> a
compareOrd
instance C Ordering where
{-# INLINE compare #-}
compare :: Ordering
-> Ordering -> Ordering -> Ordering -> Ordering -> Ordering
compare = Ordering
-> Ordering -> Ordering -> Ordering -> Ordering -> Ordering
forall a. Ord a => a -> a -> a -> a -> a -> a
compareOrd
{-# INLINE elementCompare #-}
elementCompare ::
(C x) =>
(v -> x) -> Elem.T (v,v,v,v,v) x
elementCompare :: (v -> x) -> T (v, v, v, v, v) x
elementCompare v -> x
f =
((v, v, v, v, v) -> x) -> T (v, v, v, v, v) x
forall v a. (v -> a) -> T v a
Elem.element (\(v
x,v
y,v
lt,v
eq,v
gt) ->
x -> x -> x -> x -> x -> x
forall a. C a => a -> a -> a -> a -> a -> a
compare (v -> x
f v
x) (v -> x
f v
y) (v -> x
f v
lt) (v -> x
f v
eq) (v -> x
f v
gt))
{-# INLINE (<*>.<=>?) #-}
(<*>.<=>?) ::
(C x) =>
Elem.T (v,v,v,v,v) (x -> a) -> (v -> x) -> Elem.T (v,v,v,v,v) a
<*>.<=>? :: T (v, v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v, v) a
(<*>.<=>?) T (v, v, v, v, v) (x -> a)
f v -> x
acc =
T (v, v, v, v, v) (x -> a)
f T (v, v, v, v, v) (x -> a)
-> T (v, v, v, v, v) x -> T (v, v, v, v, v) a
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (v -> x) -> T (v, v, v, v, v) x
forall x v. C x => (v -> x) -> T (v, v, v, v, v) x
elementCompare v -> x
acc
{-# INLINE element #-}
element ::
(C x) =>
(x -> x -> x -> x -> x) ->
(v -> x) -> Elem.T (v,v,v,v) x
element :: (x -> x -> x -> x -> x) -> (v -> x) -> T (v, v, v, v) x
element x -> x -> x -> x -> x
cmp v -> x
f =
((v, v, v, v) -> x) -> T (v, v, v, v) x
forall v a. (v -> a) -> T v a
Elem.element (\(v
x,v
y,v
true,v
false) -> x -> x -> x -> x -> x
cmp (v -> x
f v
x) (v -> x
f v
y) (v -> x
f v
true) (v -> x
f v
false))
{-# INLINE (<*>.<=?) #-}
(<*>.<=?) ::
(C x) =>
Elem.T (v,v,v,v) (x -> a) -> (v -> x) -> Elem.T (v,v,v,v) a
<*>.<=? :: T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
(<*>.<=?) T (v, v, v, v) (x -> a)
f v -> x
acc =
T (v, v, v, v) (x -> a)
f T (v, v, v, v) (x -> a) -> T (v, v, v, v) x -> T (v, v, v, v) a
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (x -> x -> x -> x -> x) -> (v -> x) -> T (v, v, v, v) x
forall x v.
C x =>
(x -> x -> x -> x -> x) -> (v -> x) -> T (v, v, v, v) x
element x -> x -> x -> x -> x
forall a. C a => a -> a -> a -> a -> a
(<=?) v -> x
acc
{-# INLINE (<*>.>=?) #-}
(<*>.>=?) ::
(C x) =>
Elem.T (v,v,v,v) (x -> a) -> (v -> x) -> Elem.T (v,v,v,v) a
<*>.>=? :: T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
(<*>.>=?) T (v, v, v, v) (x -> a)
f v -> x
acc =
T (v, v, v, v) (x -> a)
f T (v, v, v, v) (x -> a) -> T (v, v, v, v) x -> T (v, v, v, v) a
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (x -> x -> x -> x -> x) -> (v -> x) -> T (v, v, v, v) x
forall x v.
C x =>
(x -> x -> x -> x -> x) -> (v -> x) -> T (v, v, v, v) x
element x -> x -> x -> x -> x
forall a. C a => a -> a -> a -> a -> a
(>=?) v -> x
acc
{-# INLINE (<*>.<?) #-}
(<*>.<?) ::
(C x) =>
Elem.T (v,v,v,v) (x -> a) -> (v -> x) -> Elem.T (v,v,v,v) a
<*>.<? :: T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
(<*>.<?) T (v, v, v, v) (x -> a)
f v -> x
acc =
T (v, v, v, v) (x -> a)
f T (v, v, v, v) (x -> a) -> T (v, v, v, v) x -> T (v, v, v, v) a
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (x -> x -> x -> x -> x) -> (v -> x) -> T (v, v, v, v) x
forall x v.
C x =>
(x -> x -> x -> x -> x) -> (v -> x) -> T (v, v, v, v) x
element x -> x -> x -> x -> x
forall a. C a => a -> a -> a -> a -> a
(<?) v -> x
acc
{-# INLINE (<*>.>?) #-}
(<*>.>?) ::
(C x) =>
Elem.T (v,v,v,v) (x -> a) -> (v -> x) -> Elem.T (v,v,v,v) a
<*>.>? :: T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
(<*>.>?) T (v, v, v, v) (x -> a)
f v -> x
acc =
T (v, v, v, v) (x -> a)
f T (v, v, v, v) (x -> a) -> T (v, v, v, v) x -> T (v, v, v, v) a
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (x -> x -> x -> x -> x) -> (v -> x) -> T (v, v, v, v) x
forall x v.
C x =>
(x -> x -> x -> x -> x) -> (v -> x) -> T (v, v, v, v) x
element x -> x -> x -> x -> x
forall a. C a => a -> a -> a -> a -> a
(>?) v -> x
acc
instance (C a, C b) => C (a,b) where
{-# INLINE compare #-}
compare :: (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
compare = T ((a, b), (a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
forall x y z u w a.
T (x, y, z, u, w) a -> x -> y -> z -> u -> w -> a
Elem.run5 (T ((a, b), (a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
forall a b. (a -> b) -> a -> b
$ (a -> b -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,) T ((a, b), (a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
-> ((a, b) -> a)
-> T ((a, b), (a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
forall x v a.
C x =>
T (v, v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v, v) a
<*>.<=>? (a, b) -> a
forall a b. (a, b) -> a
fst T ((a, b), (a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
-> ((a, b) -> b)
-> T ((a, b), (a, b), (a, b), (a, b), (a, b)) (a, b)
forall x v a.
C x =>
T (v, v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v, v) a
<*>.<=>? (a, b) -> b
forall a b. (a, b) -> b
snd
{-# INLINE (<=?) #-}
<=? :: (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
(<=?) = T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
forall x y z w a. T (x, y, z, w) a -> x -> y -> z -> w -> a
Elem.run4 (T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
forall a b. (a -> b) -> a -> b
$ (a -> b -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,) T ((a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
-> ((a, b) -> a)
-> T ((a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<=? (a, b) -> a
forall a b. (a, b) -> a
fst T ((a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
-> ((a, b) -> b) -> T ((a, b), (a, b), (a, b), (a, b)) (a, b)
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<=? (a, b) -> b
forall a b. (a, b) -> b
snd
{-# INLINE (>=?) #-}
>=? :: (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
(>=?) = T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
forall x y z w a. T (x, y, z, w) a -> x -> y -> z -> w -> a
Elem.run4 (T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
forall a b. (a -> b) -> a -> b
$ (a -> b -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,) T ((a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
-> ((a, b) -> a)
-> T ((a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>=? (a, b) -> a
forall a b. (a, b) -> a
fst T ((a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
-> ((a, b) -> b) -> T ((a, b), (a, b), (a, b), (a, b)) (a, b)
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>=? (a, b) -> b
forall a b. (a, b) -> b
snd
{-# INLINE (<?) #-}
<? :: (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
(<?) = T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
forall x y z w a. T (x, y, z, w) a -> x -> y -> z -> w -> a
Elem.run4 (T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
forall a b. (a -> b) -> a -> b
$ (a -> b -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,) T ((a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
-> ((a, b) -> a)
-> T ((a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<? (a, b) -> a
forall a b. (a, b) -> a
fst T ((a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
-> ((a, b) -> b) -> T ((a, b), (a, b), (a, b), (a, b)) (a, b)
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<? (a, b) -> b
forall a b. (a, b) -> b
snd
{-# INLINE (>?) #-}
>? :: (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
(>?) = T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b)
forall x y z w a. T (x, y, z, w) a -> x -> y -> z -> w -> a
Elem.run4 (T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b) -> (a, b) -> (a, b) -> (a, b) -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b)) (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
-> (a, b)
forall a b. (a -> b) -> a -> b
$ (a -> b -> (a, b))
-> T ((a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,) T ((a, b), (a, b), (a, b), (a, b)) (a -> b -> (a, b))
-> ((a, b) -> a)
-> T ((a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>? (a, b) -> a
forall a b. (a, b) -> a
fst T ((a, b), (a, b), (a, b), (a, b)) (b -> (a, b))
-> ((a, b) -> b) -> T ((a, b), (a, b), (a, b), (a, b)) (a, b)
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>? (a, b) -> b
forall a b. (a, b) -> b
snd
instance (C a, C b, C c) => C (a,b,c) where
{-# INLINE compare #-}
compare :: (a, b, c)
-> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c)
compare = T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
forall x y z u w a.
T (x, y, z, u, w) a -> x -> y -> z -> u -> w -> a
Elem.run5 (T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,) T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
-> ((a, b, c) -> a)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v, v) a
<*>.<=>? (a, b, c) -> a
forall a b c. (a, b, c) -> a
fst3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
-> ((a, b, c) -> b)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c))
(c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v, v) a
<*>.<=>? (a, b, c) -> b
forall a b c. (a, b, c) -> b
snd3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c))
(c -> (a, b, c))
-> ((a, b, c) -> c)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a, b, c)
forall x v a.
C x =>
T (v, v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v, v) a
<*>.<=>? (a, b, c) -> c
forall a b c. (a, b, c) -> c
thd3
{-# INLINE (<=?) #-}
<=? :: (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c)
(<=?) = T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c)
forall x y z w a. T (x, y, z, w) a -> x -> y -> z -> w -> a
Elem.run4 (T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,) T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
-> ((a, b, c) -> a)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<=? (a, b, c) -> a
forall a b c. (a, b, c) -> a
fst3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
-> ((a, b, c) -> b)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<=? (a, b, c) -> b
forall a b c. (a, b, c) -> b
snd3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (c -> (a, b, c))
-> ((a, b, c) -> c)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<=? (a, b, c) -> c
forall a b c. (a, b, c) -> c
thd3
{-# INLINE (>=?) #-}
>=? :: (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c)
(>=?) = T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c)
forall x y z w a. T (x, y, z, w) a -> x -> y -> z -> w -> a
Elem.run4 (T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,) T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
-> ((a, b, c) -> a)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>=? (a, b, c) -> a
forall a b c. (a, b, c) -> a
fst3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
-> ((a, b, c) -> b)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>=? (a, b, c) -> b
forall a b c. (a, b, c) -> b
snd3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (c -> (a, b, c))
-> ((a, b, c) -> c)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>=? (a, b, c) -> c
forall a b c. (a, b, c) -> c
thd3
{-# INLINE (<?) #-}
<? :: (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c)
(<?) = T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c)
forall x y z w a. T (x, y, z, w) a -> x -> y -> z -> w -> a
Elem.run4 (T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,) T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
-> ((a, b, c) -> a)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<? (a, b, c) -> a
forall a b c. (a, b, c) -> a
fst3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
-> ((a, b, c) -> b)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<? (a, b, c) -> b
forall a b c. (a, b, c) -> b
snd3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (c -> (a, b, c))
-> ((a, b, c) -> c)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.<? (a, b, c) -> c
forall a b c. (a, b, c) -> c
thd3
{-# INLINE (>?) #-}
>? :: (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c)
(>?) = T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c)
forall x y z w a. T (x, y, z, w) a -> x -> y -> z -> w -> a
Elem.run4 (T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c) -> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
-> (a, b, c)
forall a b. (a -> b) -> a -> b
$ (a -> b -> c -> (a, b, c))
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (,,) T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(a -> b -> c -> (a, b, c))
-> ((a, b, c) -> a)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>? (a, b, c) -> a
forall a b c. (a, b, c) -> a
fst3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c))
(b -> c -> (a, b, c))
-> ((a, b, c) -> b)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (c -> (a, b, c))
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>? (a, b, c) -> b
forall a b c. (a, b, c) -> b
snd3 T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (c -> (a, b, c))
-> ((a, b, c) -> c)
-> T ((a, b, c), (a, b, c), (a, b, c), (a, b, c)) (a, b, c)
forall x v a.
C x =>
T (v, v, v, v) (x -> a) -> (v -> x) -> T (v, v, v, v) a
<*>.>? (a, b, c) -> c
forall a b c. (a, b, c) -> c
thd3
instance C a => C [a] where
{-# INLINE compare #-}
compare :: [a] -> [a] -> [a] -> [a] -> [a] -> [a]
compare = (a -> a -> a -> a -> a -> a)
-> [a] -> [a] -> [a] -> [a] -> [a] -> [a]
forall a b c d e f.
(a -> b -> c -> d -> e -> f)
-> [a] -> [b] -> [c] -> [d] -> [e] -> [f]
zipWith5 a -> a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a -> a
compare
{-# INLINE (<=?) #-}
<=? :: [a] -> [a] -> [a] -> [a] -> [a]
(<=?) = (a -> a -> a -> a -> a) -> [a] -> [a] -> [a] -> [a] -> [a]
forall a b c d e.
(a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]
zipWith4 a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
(<=?)
{-# INLINE (>=?) #-}
>=? :: [a] -> [a] -> [a] -> [a] -> [a]
(>=?) = (a -> a -> a -> a -> a) -> [a] -> [a] -> [a] -> [a] -> [a]
forall a b c d e.
(a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]
zipWith4 a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
(>=?)
{-# INLINE (<?) #-}
<? :: [a] -> [a] -> [a] -> [a] -> [a]
(<?) = (a -> a -> a -> a -> a) -> [a] -> [a] -> [a] -> [a] -> [a]
forall a b c d e.
(a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]
zipWith4 a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
(<?)
{-# INLINE (>?) #-}
>? :: [a] -> [a] -> [a] -> [a] -> [a]
(>?) = (a -> a -> a -> a -> a) -> [a] -> [a] -> [a] -> [a] -> [a]
forall a b c d e.
(a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]
zipWith4 a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
(>?)
instance (C a) => C (b -> a) where
{-# INLINE compare #-}
compare :: (b -> a) -> (b -> a) -> (b -> a) -> (b -> a) -> (b -> a) -> b -> a
compare b -> a
x b -> a
y b -> a
lt b -> a
eq b -> a
gt b
c = a -> a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a -> a
compare (b -> a
x b
c) (b -> a
y b
c) (b -> a
lt b
c) (b -> a
eq b
c) (b -> a
gt b
c)
{-# INLINE (<=?) #-}
<=? :: (b -> a) -> (b -> a) -> (b -> a) -> (b -> a) -> b -> a
(<=?) b -> a
x b -> a
y b -> a
true b -> a
false b
c = (b -> a
x b
c a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
<=? b -> a
y b
c) (b -> a
true b
c) (b -> a
false b
c)
{-# INLINE (>=?) #-}
>=? :: (b -> a) -> (b -> a) -> (b -> a) -> (b -> a) -> b -> a
(>=?) b -> a
x b -> a
y b -> a
true b -> a
false b
c = (b -> a
x b
c a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
>=? b -> a
y b
c) (b -> a
true b
c) (b -> a
false b
c)
{-# INLINE (<?) #-}
<? :: (b -> a) -> (b -> a) -> (b -> a) -> (b -> a) -> b -> a
(<?) b -> a
x b -> a
y b -> a
true b -> a
false b
c = (b -> a
x b
c a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
<? b -> a
y b
c) (b -> a
true b
c) (b -> a
false b
c)
{-# INLINE (>?) #-}
>? :: (b -> a) -> (b -> a) -> (b -> a) -> (b -> a) -> b -> a
(>?) b -> a
x b -> a
y b -> a
true b -> a
false b
c = (b -> a
x b
c a -> a -> a -> a -> a
forall a. C a => a -> a -> a -> a -> a
>? b -> a
y b
c) (b -> a
true b
c) (b -> a
false b
c)