Copyright | (c) Justin Le 2021 |
---|---|
License | BSD-3 |
Maintainer | justin@jle.im |
Stability | unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Derived methods for Eq
and Ord
, using Generics.OneLiner and
GHC.Generics.
Can be used for any types (deriving Generic
) where every field is an
instance of Eq
(or Ord
).
Also includes a newtype wrapper that imbues any such data type with
instant Eq
and Ord
instances, which can one day be used with
DerivingVia syntax to derive instances automatically.
Synopsis
- newtype GOrd a = GOrd {
- getGOrd :: a
- gEquals :: forall a. (ADT a, Constraints a Eq) => a -> a -> Bool
- gNotEquals :: forall a. (ADT a, Constraints a Eq) => a -> a -> Bool
- gCompare :: forall a. (ADT a, Constraints a Ord) => a -> a -> Ordering
- gLTE :: forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
- gLT :: forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
- gGTE :: forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
- gGT :: forall a. (ADT a, Constraints a Ord) => a -> a -> Bool
- gMax :: forall a. (ADT a, Constraints a Ord) => a -> a -> a
- gMin :: forall a. (ADT a, Constraints a Ord) => a -> a -> a
Newtype wrapper
If a
is a data type whose fields are all instances of Eq
, then
has a GOrd
aEq
instance.
If a
is a data type whose fields are all instances of Ord
, then
has a GOrd
aOrd
instance.
Will one day be able to be used with DerivingVia syntax, to derive instances automatically.
Instances
Functor GOrd Source # | |
Foldable GOrd Source # | |
Defined in Data.Ord.OneLiner fold :: Monoid m => GOrd m -> m # foldMap :: Monoid m => (a -> m) -> GOrd a -> m # foldMap' :: Monoid m => (a -> m) -> GOrd a -> m # foldr :: (a -> b -> b) -> b -> GOrd a -> b # foldr' :: (a -> b -> b) -> b -> GOrd a -> b # foldl :: (b -> a -> b) -> b -> GOrd a -> b # foldl' :: (b -> a -> b) -> b -> GOrd a -> b # foldr1 :: (a -> a -> a) -> GOrd a -> a # foldl1 :: (a -> a -> a) -> GOrd a -> a # elem :: Eq a => a -> GOrd a -> Bool # maximum :: Ord a => GOrd a -> a # | |
Traversable GOrd Source # | |
(ADT a, Constraints a Eq) => Eq (GOrd a) Source # | |
Data a => Data (GOrd a) Source # | |
Defined in Data.Ord.OneLiner gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GOrd a -> c (GOrd a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GOrd a) # toConstr :: GOrd a -> Constr # dataTypeOf :: GOrd a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (GOrd a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GOrd a)) # gmapT :: (forall b. Data b => b -> b) -> GOrd a -> GOrd a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GOrd a -> r # gmapQ :: (forall d. Data d => d -> u) -> GOrd a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> GOrd a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GOrd a -> m (GOrd a) # | |
(ADT a, Constraints a Eq, Constraints a Ord) => Ord (GOrd a) Source # | |
Read a => Read (GOrd a) Source # | |
Show a => Show (GOrd a) Source # | |
Generic (GOrd a) Source # | |
type Rep (GOrd a) Source # | |
Defined in Data.Ord.OneLiner |
Generics-derived methods
Eq
gNotEquals :: forall a. (ADT a, Constraints a Eq) => a -> a -> Bool Source #