generic-data-0.8.3.0: Deriving instances with GHC.Generics and related utilities

Safe HaskellSafe
LanguageHaskell2010

Generic.Data.Internal.Prelude

Contents

Description

Generic deriving for standard classes in base

Warning

This is an internal module: it is not subject to any versioning policy, breaking changes can happen at any time.

If something here seems useful, please report it or create a pull request to export it from an external module.

Synopsis

Eq

geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool Source #

Generic (==).

instance Eq MyType where
  (==) = geq

Ord

gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering Source #

Generic compare.

instance Ord MyType where
  compare = gcompare

Semigroup

gmappend :: (Generic a, Semigroup (Rep a ())) => a -> a -> a Source #

Generic (<>) (or mappend).

instance Semigroup MyType where
  (<>) = gmappend

See also gmempty.

Monoid

gmempty :: (Generic a, Monoid (Rep a ())) => a Source #

Generic mempty.

instance Monoid MyType where
  mempty = gmempty

gmappend' :: (Generic a, Monoid (Rep a ())) => a -> a -> a Source #

Generic (<>) (or mappend).

The difference from gmappend is the Monoid constraint instead of Semigroup, for older versions of base where Semigroup is not a superclass of Monoid.

Functor

gfmap :: (Generic1 f, Functor (Rep1 f)) => (a -> b) -> f a -> f b Source #

Generic fmap.

instance Functor MyTypeF where
  fmap = gfmap

gconstmap :: (Generic1 f, Functor (Rep1 f)) => a -> f b -> f a Source #

Generic (<$).

See also gfmap.

Applicative

gpure :: (Generic1 f, Applicative (Rep1 f)) => a -> f a Source #

Generic pure.

instance Applicative MyTypeF where
  pure = gpure
  (<*>) = gap

gap :: (Generic1 f, Applicative (Rep1 f)) => f (a -> b) -> f a -> f b Source #

Generic (<*>) (or ap).

See also gpure.

gliftA2 :: (Generic1 f, Applicative (Rep1 f)) => (a -> b -> c) -> f a -> f b -> f c Source #

Generic liftA2.

See also gpure.

Alternative

gempty :: (Generic1 f, Alternative (Rep1 f)) => f a Source #

Generic empty.

instance Alternative MyTypeF where
  empty = gempty
  (<|>) = galt

galt :: (Generic1 f, Alternative (Rep1 f)) => f a -> f a -> f a Source #

Generic (<|>).

See also gempty.

Foldable

gfoldMap :: (Generic1 f, Foldable (Rep1 f), Monoid m) => (a -> m) -> f a -> m Source #

Generic foldMap.

instance Foldable MyTypeF where
  foldMap = gfoldMap

gfoldr :: (Generic1 f, Foldable (Rep1 f)) => (a -> b -> b) -> b -> f a -> b Source #

Generic foldr.

instance Foldable MyTypeF where
  foldr = gfoldr

See also gfoldMap.

Traversable

gtraverse :: (Generic1 f, Traversable (Rep1 f), Applicative m) => (a -> m b) -> f a -> m (f b) Source #

Generic traverse.

instance Traversable MyTypeF where
  traverse = gtraverse

gsequenceA :: (Generic1 f, Traversable (Rep1 f), Applicative m) => f (m a) -> m (f a) Source #

Generic sequenceA.

instance Traversable MyTypeF where
  sequenceA = gsequenceA

See also gtraverse.

Eq1

gliftEq :: (Generic1 f, Eq1 (Rep1 f)) => (a -> b -> Bool) -> f a -> f b -> Bool Source #

Generic liftEq.

Ord1

gliftCompare :: (Generic1 f, Ord1 (Rep1 f)) => (a -> b -> Ordering) -> f a -> f b -> Ordering Source #

Generic liftCompare.