{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
module Data.Ord.OneLiner (
GOrd(..)
, gEquals
, gNotEquals
, gCompare
, gLTE
, gLT
, gGTE
, gGT
, gMax
, gMin
) where
import Data.Coerce
import Data.Data
import Data.Monoid
import GHC.Generics
import Generics.OneLiner
newtype GOrd a = GOrd { GOrd a -> a
getGOrd :: a }
deriving (Int -> GOrd a -> ShowS
[GOrd a] -> ShowS
GOrd a -> String
(Int -> GOrd a -> ShowS)
-> (GOrd a -> String) -> ([GOrd a] -> ShowS) -> Show (GOrd a)
forall a. Show a => Int -> GOrd a -> ShowS
forall a. Show a => [GOrd a] -> ShowS
forall a. Show a => GOrd a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GOrd a] -> ShowS
$cshowList :: forall a. Show a => [GOrd a] -> ShowS
show :: GOrd a -> String
$cshow :: forall a. Show a => GOrd a -> String
showsPrec :: Int -> GOrd a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> GOrd a -> ShowS
Show, ReadPrec [GOrd a]
ReadPrec (GOrd a)
Int -> ReadS (GOrd a)
ReadS [GOrd a]
(Int -> ReadS (GOrd a))
-> ReadS [GOrd a]
-> ReadPrec (GOrd a)
-> ReadPrec [GOrd a]
-> Read (GOrd a)
forall a. Read a => ReadPrec [GOrd a]
forall a. Read a => ReadPrec (GOrd a)
forall a. Read a => Int -> ReadS (GOrd a)
forall a. Read a => ReadS [GOrd a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GOrd a]
$creadListPrec :: forall a. Read a => ReadPrec [GOrd a]
readPrec :: ReadPrec (GOrd a)
$creadPrec :: forall a. Read a => ReadPrec (GOrd a)
readList :: ReadS [GOrd a]
$creadList :: forall a. Read a => ReadS [GOrd a]
readsPrec :: Int -> ReadS (GOrd a)
$creadsPrec :: forall a. Read a => Int -> ReadS (GOrd a)
Read, Typeable (GOrd a)
DataType
Constr
Typeable (GOrd a)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GOrd a -> c (GOrd a))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GOrd a))
-> (GOrd a -> Constr)
-> (GOrd a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (GOrd a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GOrd a)))
-> ((forall b. Data b => b -> b) -> GOrd a -> GOrd a)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> GOrd a -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> GOrd a -> r)
-> (forall u. (forall d. Data d => d -> u) -> GOrd a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> GOrd a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a))
-> Data (GOrd a)
GOrd a -> DataType
GOrd a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (GOrd a))
(forall b. Data b => b -> b) -> GOrd a -> GOrd a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GOrd a -> c (GOrd a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GOrd a)
forall a. Data a => Typeable (GOrd a)
forall a. Data a => GOrd a -> DataType
forall a. Data a => GOrd a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> GOrd a -> GOrd a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> GOrd a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> GOrd a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GOrd a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GOrd a -> c (GOrd a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (GOrd a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GOrd a))
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) -> GOrd a -> u
forall u. (forall d. Data d => d -> u) -> GOrd a -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GOrd a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GOrd a -> c (GOrd a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (GOrd a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GOrd a))
$cGOrd :: Constr
$tGOrd :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
gmapMp :: (forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
gmapM :: (forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> GOrd a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> GOrd a -> u
gmapQ :: (forall d. Data d => d -> u) -> GOrd a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> GOrd a -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r
gmapT :: (forall b. Data b => b -> b) -> GOrd a -> GOrd a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> GOrd a -> GOrd a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GOrd a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GOrd a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (GOrd a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (GOrd a))
dataTypeOf :: GOrd a -> DataType
$cdataTypeOf :: forall a. Data a => GOrd a -> DataType
toConstr :: GOrd a -> Constr
$ctoConstr :: forall a. Data a => GOrd a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GOrd a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (GOrd a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GOrd a -> c (GOrd a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> GOrd a -> c (GOrd a)
$cp1Data :: forall a. Data a => Typeable (GOrd a)
Data, (forall x. GOrd a -> Rep (GOrd a) x)
-> (forall x. Rep (GOrd a) x -> GOrd a) -> Generic (GOrd a)
forall x. Rep (GOrd a) x -> GOrd a
forall x. GOrd a -> Rep (GOrd a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (GOrd a) x -> GOrd a
forall a x. GOrd a -> Rep (GOrd a) x
$cto :: forall a x. Rep (GOrd a) x -> GOrd a
$cfrom :: forall a x. GOrd a -> Rep (GOrd a) x
Generic, a -> GOrd b -> GOrd a
(a -> b) -> GOrd a -> GOrd b
(forall a b. (a -> b) -> GOrd a -> GOrd b)
-> (forall a b. a -> GOrd b -> GOrd a) -> Functor GOrd
forall a b. a -> GOrd b -> GOrd a
forall a b. (a -> b) -> GOrd a -> GOrd b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> GOrd b -> GOrd a
$c<$ :: forall a b. a -> GOrd b -> GOrd a
fmap :: (a -> b) -> GOrd a -> GOrd b
$cfmap :: forall a b. (a -> b) -> GOrd a -> GOrd b
Functor, GOrd a -> Bool
(a -> m) -> GOrd a -> m
(a -> b -> b) -> b -> GOrd a -> b
(forall m. Monoid m => GOrd m -> m)
-> (forall m a. Monoid m => (a -> m) -> GOrd a -> m)
-> (forall m a. Monoid m => (a -> m) -> GOrd a -> m)
-> (forall a b. (a -> b -> b) -> b -> GOrd a -> b)
-> (forall a b. (a -> b -> b) -> b -> GOrd a -> b)
-> (forall b a. (b -> a -> b) -> b -> GOrd a -> b)
-> (forall b a. (b -> a -> b) -> b -> GOrd a -> b)
-> (forall a. (a -> a -> a) -> GOrd a -> a)
-> (forall a. (a -> a -> a) -> GOrd a -> a)
-> (forall a. GOrd a -> [a])
-> (forall a. GOrd a -> Bool)
-> (forall a. GOrd a -> Int)
-> (forall a. Eq a => a -> GOrd a -> Bool)
-> (forall a. Ord a => GOrd a -> a)
-> (forall a. Ord a => GOrd a -> a)
-> (forall a. Num a => GOrd a -> a)
-> (forall a. Num a => GOrd a -> a)
-> Foldable GOrd
forall a. Eq a => a -> GOrd a -> Bool
forall a. Num a => GOrd a -> a
forall a. Ord a => GOrd a -> a
forall m. Monoid m => GOrd m -> m
forall a. GOrd a -> Bool
forall a. GOrd a -> Int
forall a. GOrd a -> [a]
forall a. (a -> a -> a) -> GOrd a -> a
forall m a. Monoid m => (a -> m) -> GOrd a -> m
forall b a. (b -> a -> b) -> b -> GOrd a -> b
forall a b. (a -> b -> b) -> b -> GOrd 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 :: GOrd a -> a
$cproduct :: forall a. Num a => GOrd a -> a
sum :: GOrd a -> a
$csum :: forall a. Num a => GOrd a -> a
minimum :: GOrd a -> a
$cminimum :: forall a. Ord a => GOrd a -> a
maximum :: GOrd a -> a
$cmaximum :: forall a. Ord a => GOrd a -> a
elem :: a -> GOrd a -> Bool
$celem :: forall a. Eq a => a -> GOrd a -> Bool
length :: GOrd a -> Int
$clength :: forall a. GOrd a -> Int
null :: GOrd a -> Bool
$cnull :: forall a. GOrd a -> Bool
toList :: GOrd a -> [a]
$ctoList :: forall a. GOrd a -> [a]
foldl1 :: (a -> a -> a) -> GOrd a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> GOrd a -> a
foldr1 :: (a -> a -> a) -> GOrd a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> GOrd a -> a
foldl' :: (b -> a -> b) -> b -> GOrd a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> GOrd a -> b
foldl :: (b -> a -> b) -> b -> GOrd a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> GOrd a -> b
foldr' :: (a -> b -> b) -> b -> GOrd a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> GOrd a -> b
foldr :: (a -> b -> b) -> b -> GOrd a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> GOrd a -> b
foldMap' :: (a -> m) -> GOrd a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> GOrd a -> m
foldMap :: (a -> m) -> GOrd a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> GOrd a -> m
fold :: GOrd m -> m
$cfold :: forall m. Monoid m => GOrd m -> m
Foldable, Functor GOrd
Foldable GOrd
Functor GOrd
-> Foldable GOrd
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GOrd a -> f (GOrd b))
-> (forall (f :: * -> *) a.
Applicative f =>
GOrd (f a) -> f (GOrd a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GOrd a -> m (GOrd b))
-> (forall (m :: * -> *) a. Monad m => GOrd (m a) -> m (GOrd a))
-> Traversable GOrd
(a -> f b) -> GOrd a -> f (GOrd 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 => GOrd (m a) -> m (GOrd a)
forall (f :: * -> *) a. Applicative f => GOrd (f a) -> f (GOrd a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GOrd a -> m (GOrd b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GOrd a -> f (GOrd b)
sequence :: GOrd (m a) -> m (GOrd a)
$csequence :: forall (m :: * -> *) a. Monad m => GOrd (m a) -> m (GOrd a)
mapM :: (a -> m b) -> GOrd a -> m (GOrd b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GOrd a -> m (GOrd b)
sequenceA :: GOrd (f a) -> f (GOrd a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => GOrd (f a) -> f (GOrd a)
traverse :: (a -> f b) -> GOrd a -> f (GOrd b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GOrd a -> f (GOrd b)
$cp2Traversable :: Foldable GOrd
$cp1Traversable :: Functor GOrd
Traversable)
instance ( ADT a
, Constraints a Eq
)
=> Eq (GOrd a) where
== :: GOrd a -> GOrd a -> Bool
(==) = (a -> a -> Bool) -> GOrd a -> GOrd a -> Bool
coerce ((ADT a, Constraints a Eq) => a -> a -> Bool
forall a. (ADT a, Constraints a Eq) => a -> a -> Bool
gEquals @a)
{-# INLINE (==) #-}
/= :: GOrd a -> GOrd a -> Bool
(/=) = (a -> a -> Bool) -> GOrd a -> GOrd a -> Bool
coerce ((ADT a, Constraints a Eq) => a -> a -> Bool
forall a. (ADT a, Constraints a Eq) => a -> a -> Bool
gNotEquals @a)
{-# INLINE (/=) #-}
instance ( ADT a
, Constraints a Eq
, Constraints a Ord
)
=> Ord (GOrd a) where
compare :: GOrd a -> GOrd a -> Ordering
compare = (a -> a -> Ordering) -> GOrd a -> GOrd a -> Ordering
coerce ((ADT a, Constraints a Ord) => a -> a -> Ordering
forall a. (ADT a, Constraints a Ord) => a -> a -> Ordering
gCompare @a)
{-# INLINE compare #-}
<= :: GOrd a -> GOrd a -> Bool
(<=) = (a -> a -> Bool) -> GOrd a -> GOrd a -> Bool
coerce ((ADT a, Constraints a Ord) => a -> a -> Bool
forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
gLTE @a)
{-# INLINE (<=) #-}
< :: GOrd a -> GOrd a -> Bool
(<) = (a -> a -> Bool) -> GOrd a -> GOrd a -> Bool
coerce ((ADT a, Constraints a Ord) => a -> a -> Bool
forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
gLT @a)
{-# INLINE (<) #-}
>= :: GOrd a -> GOrd a -> Bool
(>=) = (a -> a -> Bool) -> GOrd a -> GOrd a -> Bool
coerce ((ADT a, Constraints a Ord) => a -> a -> Bool
forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
gGTE @a)
{-# INLINE (>=) #-}
> :: GOrd a -> GOrd a -> Bool
(>) = (a -> a -> Bool) -> GOrd a -> GOrd a -> Bool
coerce ((ADT a, Constraints a Ord) => a -> a -> Bool
forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
gGT @a)
{-# INLINE (>) #-}
max :: GOrd a -> GOrd a -> GOrd a
max = (a -> a -> a) -> GOrd a -> GOrd a -> GOrd a
coerce ((ADT a, Constraints a Ord) => a -> a -> a
forall a. (ADT a, Constraints a Ord) => a -> a -> a
gMax @a)
{-# INLINE max #-}
min :: GOrd a -> GOrd a -> GOrd a
min = (a -> a -> a) -> GOrd a -> GOrd a -> GOrd a
coerce ((ADT a, Constraints a Ord) => a -> a -> a
forall a. (ADT a, Constraints a Ord) => a -> a -> a
gMin @a)
{-# INLINE min #-}
gEquals
:: forall a. (ADT a, Constraints a Eq)
=> a -> a -> Bool
gEquals :: a -> a -> Bool
gEquals a
x a
y = a -> Int
forall t. ADT t => t -> Int
ctorIndex a
x Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== a -> Int
forall t. ADT t => t -> Int
ctorIndex a
y
Bool -> Bool -> Bool
&& All -> Bool
getAll ((forall s. Eq s => s -> s -> All) -> a -> a -> All
forall (c :: * -> Constraint) t m.
(ADT t, Constraints t c, Monoid m) =>
(forall s. c s => s -> s -> m) -> t -> t -> m
mzipWith @Eq (\s
x' -> Bool -> All
All (Bool -> All) -> (s -> Bool) -> s -> All
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (s -> s -> Bool
forall a. Eq a => a -> a -> Bool
== s
x')) a
x a
y)
{-# INLINE gEquals #-}
gNotEquals
:: forall a. (ADT a, Constraints a Eq)
=> a -> a -> Bool
gNotEquals :: a -> a -> Bool
gNotEquals a
x a
y = a -> Int
forall t. ADT t => t -> Int
ctorIndex a
x Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= a -> Int
forall t. ADT t => t -> Int
ctorIndex a
y
Bool -> Bool -> Bool
|| Any -> Bool
getAny ((forall s. Eq s => s -> s -> Any) -> a -> a -> Any
forall (c :: * -> Constraint) t m.
(ADT t, Constraints t c, Monoid m) =>
(forall s. c s => s -> s -> m) -> t -> t -> m
mzipWith @Eq (\s
x' -> Bool -> Any
Any (Bool -> Any) -> (s -> Bool) -> s -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (s -> s -> Bool
forall a. Eq a => a -> a -> Bool
/= s
x')) a
x a
y)
{-# INLINE gNotEquals #-}
gCompare
:: forall a. (ADT a, Constraints a Ord)
=> a -> a -> Ordering
gCompare :: a -> a -> Ordering
gCompare a
x a
y = Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (a -> Int
forall t. ADT t => t -> Int
ctorIndex a
x) (a -> Int
forall t. ADT t => t -> Int
ctorIndex a
y)
Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> (forall a. Ord a => a -> a -> Ordering) -> a -> a -> Ordering
forall (c :: * -> Constraint) t m.
(ADT t, Constraints t c, Monoid m) =>
(forall s. c s => s -> s -> m) -> t -> t -> m
mzipWith @Ord forall a. Ord a => a -> a -> Ordering
compare a
x a
y
{-# INLINE gCompare #-}
gLTE
:: forall a. (ADT a, Constraints a Ord)
=> a -> a -> Bool
gLTE :: a -> a -> Bool
gLTE a
x a
y = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ a -> a -> Bool
forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
gGT a
x a
y
{-# INLINE gLTE #-}
gLT :: forall a. (ADT a, Constraints a Ord)
=> a -> a -> Bool
gLT :: a -> a -> Bool
gLT a
x a
y = a -> Int
forall t. ADT t => t -> Int
ctorIndex a
x Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< a -> Int
forall t. ADT t => t -> Int
ctorIndex a
y
Bool -> Bool -> Bool
|| Any -> Bool
getAny ((forall s. Ord s => s -> s -> Any) -> a -> a -> Any
forall (c :: * -> Constraint) t m.
(ADT t, Constraints t c, Monoid m) =>
(forall s. c s => s -> s -> m) -> t -> t -> m
mzipWith @Ord (\s
x' -> Bool -> Any
Any (Bool -> Any) -> (s -> Bool) -> s -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (s
x' s -> s -> Bool
forall a. Ord a => a -> a -> Bool
<)) a
x a
y)
{-# INLINE gLT #-}
gGTE
:: forall a. (ADT a, Constraints a Ord)
=> a -> a -> Bool
gGTE :: a -> a -> Bool
gGTE a
x a
y = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ a -> a -> Bool
forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
gLT a
x a
y
{-# INLINE gGTE #-}
gGT :: forall a. (ADT a, Constraints a Ord)
=> a -> a -> Bool
gGT :: a -> a -> Bool
gGT a
x a
y = a -> Int
forall t. ADT t => t -> Int
ctorIndex a
x Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> a -> Int
forall t. ADT t => t -> Int
ctorIndex a
y
Bool -> Bool -> Bool
|| Any -> Bool
getAny ((forall s. Ord s => s -> s -> Any) -> a -> a -> Any
forall (c :: * -> Constraint) t m.
(ADT t, Constraints t c, Monoid m) =>
(forall s. c s => s -> s -> m) -> t -> t -> m
mzipWith @Ord (\s
x' -> Bool -> Any
Any (Bool -> Any) -> (s -> Bool) -> s -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (s
x' s -> s -> Bool
forall a. Ord a => a -> a -> Bool
>)) a
x a
y)
{-# INLINE gGT #-}
gMax
:: forall a. (ADT a, Constraints a Ord)
=> a -> a -> a
gMax :: a -> a -> a
gMax a
x a
y | a -> a -> Bool
forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
gLTE a
x a
y = a
y
| Bool
otherwise = a
x
{-# INLINE gMax #-}
gMin
:: forall a. (ADT a, Constraints a Ord)
=> a -> a -> a
gMin :: a -> a -> a
gMin a
x a
y | a -> a -> Bool
forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
gLTE a
x a
y = a
x
| Bool
otherwise = a
y
{-# INLINE gMin #-}