Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generic.Data
Description
Generic combinators to derive type class instances.
base classes that GHC can not derive instances for, as of version 8.2:
Semigroup
,Monoid
,Applicative
,Alternative
,Eq1
,Ord1
,Show1
.
On base < 4.12 (i.e., GHC < 8.6), import Generic.Data.Orphans to obtain instances needed internally to derive those.
GHC can derive instances for other classes here, although there may be types supported by one method but not the other or vice versa.
Synopsis
- gmappend :: (Generic a, Semigroup (Rep a ())) => a -> a -> a
- gmempty :: (Generic a, Monoid (Rep a ())) => a
- gmappend' :: (Generic a, Monoid (Rep a ())) => a -> a -> a
- geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool
- gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering
- gshowsPrec :: (Generic a, GShow0 (Rep a)) => Int -> a -> ShowS
- type GShow0 = GShow Proxy
- class GEnum opts f
- data StandardEnum
- gtoEnum :: forall a. (Generic a, GEnum StandardEnum (Rep a)) => Int -> a
- gfromEnum :: (Generic a, GEnum StandardEnum (Rep a)) => a -> Int
- genumFrom :: (Generic a, GEnum StandardEnum (Rep a)) => a -> [a]
- genumFromThen :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> [a]
- genumFromTo :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> [a]
- genumFromThenTo :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> a -> [a]
- data FiniteEnum
- gtoFiniteEnum :: forall a. (Generic a, GEnum FiniteEnum (Rep a)) => Int -> a
- gfromFiniteEnum :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> Int
- gfiniteEnumFrom :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> [a]
- gfiniteEnumFromThen :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> [a]
- gfiniteEnumFromTo :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> [a]
- gfiniteEnumFromThenTo :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> a -> [a]
- gminBound :: (Generic a, GBounded (Rep a)) => a
- gmaxBound :: (Generic a, GBounded (Rep a)) => a
- class GBounded f
- gfmap :: (Generic1 f, Functor (Rep1 f)) => (a -> b) -> f a -> f b
- gconstmap :: (Generic1 f, Functor (Rep1 f)) => a -> f b -> f a
- gfoldMap :: (Generic1 f, Foldable (Rep1 f), Monoid m) => (a -> m) -> f a -> m
- gfoldr :: (Generic1 f, Foldable (Rep1 f)) => (a -> b -> b) -> b -> f a -> b
- gtraverse :: (Generic1 f, Traversable (Rep1 f), Applicative m) => (a -> m b) -> f a -> m (f b)
- gsequenceA :: (Generic1 f, Traversable (Rep1 f), Applicative m) => f (m a) -> m (f a)
- gpure :: (Generic1 f, Applicative (Rep1 f)) => a -> f a
- gap :: (Generic1 f, Applicative (Rep1 f)) => f (a -> b) -> f a -> f b
- gliftA2 :: (Generic1 f, Applicative (Rep1 f)) => (a -> b -> c) -> f a -> f b -> f c
- gempty :: (Generic1 f, Alternative (Rep1 f)) => f a
- galt :: (Generic1 f, Alternative (Rep1 f)) => f a -> f a -> f a
- gliftEq :: (Generic1 f, Eq1 (Rep1 f)) => (a -> b -> Bool) -> f a -> f b -> Bool
- gliftCompare :: (Generic1 f, Ord1 (Rep1 f)) => (a -> b -> Ordering) -> f a -> f b -> Ordering
- gliftShowsPrec :: (Generic1 f, GShow1 (Rep1 f)) => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
- type GShow1 = GShow Identity
- newtype Id1 f a = Id1 {
- unId1 :: f a
- newtype Opaque a = Opaque {
- unOpaque :: a
- newtype Opaque1 f a = Opaque1 {
- unOpaque1 :: f a
- newtype Generically a = Generically {
- unGenerically :: a
- newtype FiniteEnumeration a = FiniteEnumeration {
- unFiniteEnumeration :: a
- newtype Generically1 f a = Generically1 {
- unGenerically1 :: f a
- class (Generic a, Coercible a (Old a), Newtype' a) => Newtype a
- pack :: Newtype a => Old a -> a
- unpack :: Newtype a => a -> Old a
- gcoerce :: (Generic a, Generic b, Coercible (Rep a) (Rep b)) => a -> b
- gcoerceBinop :: (Generic a, Generic b, Coercible (Rep a) (Rep b)) => (a -> a -> a) -> b -> b -> b
- gdatatypeName :: forall a. (Generic a, GDatatype (Rep a)) => String
- gmoduleName :: forall a. (Generic a, GDatatype (Rep a)) => String
- gpackageName :: forall a. (Generic a, GDatatype (Rep a)) => String
- gisNewtype :: forall a. (Generic a, GDatatype (Rep a)) => Bool
- class GDatatype f
- gconName :: forall a. Constructors a => a -> String
- gconFixity :: forall a. Constructors a => a -> Fixity
- gconIsRecord :: forall a. Constructors a => a -> Bool
- gconNum :: forall a. Constructors a => Int
- gconIndex :: forall a. Constructors a => a -> Int
- class (Generic a, GConstructors (Rep a)) => Constructors a
- class GConstructors r
- data ConId a
- conId :: forall a. Constructors a => a -> ConId a
- conIdToInt :: forall a. ConId a -> Int
- conIdToString :: forall a. Constructors a => ConId a -> String
- conIdEnum :: forall a. Constructors a => [ConId a]
- type family MetaOf (f :: * -> *) :: Meta where ...
- type family MetaDataName (m :: Meta) :: Symbol where ...
- type family MetaDataModule (m :: Meta) :: Symbol where ...
- type family MetaDataPackage (m :: Meta) :: Symbol where ...
- type family MetaDataNewtype (m :: Meta) :: Bool where ...
- type family MetaConsName (m :: Meta) :: Symbol where ...
- type family MetaConsFixity (m :: Meta) :: FixityI where ...
- type family MetaConsRecord (m :: Meta) :: Bool where ...
- type family MetaSelNameM (m :: Meta) :: Maybe Symbol where ...
- type family MetaSelName (m :: Meta) :: Symbol where ...
- type family MetaSelUnpack (m :: Meta) :: SourceUnpackedness where ...
- type family MetaSelSourceStrictness (m :: Meta) :: SourceStrictness where ...
- type family MetaSelStrictness (m :: Meta) :: DecidedStrictness where ...
Regular classes
Semigroup
Monoid
gmempty :: (Generic a, Monoid (Rep a ())) => a Source #
Generic mempty
.
instanceMonoid
MyType wheremempty
=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
.
Eq
Can also be derived by GHC as part of the standard.
geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool Source #
Generic (
.==
)
instanceEq
MyType where (==
) =geq
Ord
Can also be derived by GHC as part of the standard.
gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering Source #
Generic compare
.
instanceOrd
MyType wherecompare
=gcompare
Show
Can also be derived by GHC as part of the standard.
gshowsPrec :: (Generic a, GShow0 (Rep a)) => Int -> a -> ShowS Source #
Generic showsPrec
.
instanceShow
MyType whereshowsPrec
=gshowsPrec
Enum
Generic representation of Enum
types.
The opts
parameter is a type-level option to select different
implementations.
Minimal complete definition
Instances
GEnum opts (U1 :: Type -> Type) Source # | |
Defined in Generic.Data.Internal.Enum | |
(GEnum opts f, GEnum opts g) => GEnum opts (f :+: g) Source # | |
Defined in Generic.Data.Internal.Enum | |
(Bounded c, Enum c) => GEnum FiniteEnum (K1 i c :: Type -> Type) Source # | |
Defined in Generic.Data.Internal.Enum | |
(GEnum FiniteEnum f, GEnum FiniteEnum g) => GEnum FiniteEnum (f :*: g) Source # | |
Defined in Generic.Data.Internal.Enum | |
GEnum opts f => GEnum opts (M1 i c f) Source # | |
Defined in Generic.Data.Internal.Enum |
StandardEnum option
Can also be derived by GHC as part of the standard.
data StandardEnum Source #
Standard option for GEnum
: derive Enum
for types with only nullary
constructors (the same restrictions as in the Haskell 2010
report).
gtoEnum :: forall a. (Generic a, GEnum StandardEnum (Rep a)) => Int -> a Source #
Generic toEnum
generated with the StandardEnum
option.
instanceEnum
MyType wheretoEnum
=gtoEnum
fromEnum
=gfromEnum
enumFrom
=genumFrom
enumFromThen
=genumFromThen
enumFromTo
=genumFromTo
enumFromThenTo
=genumFromThenTo
gfromEnum :: (Generic a, GEnum StandardEnum (Rep a)) => a -> Int Source #
Generic fromEnum
generated with the StandardEnum
option.
See also gtoEnum
.
genumFrom :: (Generic a, GEnum StandardEnum (Rep a)) => a -> [a] Source #
Generic enumFrom
generated with the StandardEnum
option.
See also gtoEnum
.
genumFromThen :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> [a] Source #
Generic enumFromThen
generated with the StandardEnum
option.
See also gtoEnum
.
genumFromTo :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> [a] Source #
Generic enumFromTo
generated with the StandardEnum
option.
See also gtoEnum
.
genumFromThenTo :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> a -> [a] Source #
Generic enumFromThenTo
generated with the StandardEnum
option.
See also gtoEnum
.
FiniteEnum option
data FiniteEnum Source #
Extends the StandardEnum
option for GEnum
to allow all constructors to
have arbitrary many fields. Each field type must be an instance of
both Enum
and Bounded
. Two restrictions require the user's caution:
- The
Enum
instances of the field types need to start enumerating from 0. ParticularlyInt
is an unfit field type, because the enumeration of the negative values starts before 0. - There can only be up to
values (because the implementation represents the cardinality explicitly as anmaxBound
::Int
Int
). This restriction makesWord
an invalid field type. Notably, it is insufficient for each individual field types to stay below this limit. Instead it applies to the generic type as a whole.
The resulting GEnum
instance starts enumerating from 0
up to
(cardinality - 1)
and respects the generic Ord
instance (defined by
gcompare
). The values from different constructors are enumerated
sequentially; they are not interleaved.
data Example = C0 Bool Bool | C1 Bool deriving (Eq
,Ord
,Show
,Generic
) cardinality = 6 -- 2 * 2 + 2 -- Bool * Bool | Bool enumeration = [ C0 False False , C0 False True , C0 True False , C0 True True , C1 False , C1 True ] enumeration == mapgtoFiniteEnum
[0 .. 5] [0 .. 5] == mapgfromFiniteEnum
enumeration
Instances
(Bounded c, Enum c) => GEnum FiniteEnum (K1 i c :: Type -> Type) Source # | |
Defined in Generic.Data.Internal.Enum | |
(GEnum FiniteEnum f, GEnum FiniteEnum g) => GEnum FiniteEnum (f :*: g) Source # | |
Defined in Generic.Data.Internal.Enum |
gtoFiniteEnum :: forall a. (Generic a, GEnum FiniteEnum (Rep a)) => Int -> a Source #
Generic toEnum
generated with the FiniteEnum
option.
instanceEnum
MyType wheretoEnum
=gtoFiniteEnum
fromEnum
=gfromFiniteEnum
enumFrom
=gfiniteEnumFrom
enumFromThen
=gfiniteEnumFromThen
enumFromTo
=gfiniteEnumFromTo
enumFromThenTo
=gfiniteEnumFromThenTo
gfromFiniteEnum :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> Int Source #
Generic fromEnum
generated with the FiniteEnum
option.
See also gtoFiniteEnum
.
gfiniteEnumFrom :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> [a] Source #
Generic enumFrom
generated with the FiniteEnum
option.
See also gtoFiniteEnum
.
gfiniteEnumFromThen :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> [a] Source #
Generic enumFromThen
generated with the FiniteEnum
option.
See also gtoFiniteEnum
.
gfiniteEnumFromTo :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> [a] Source #
Generic enumFromTo
generated with the FiniteEnum
option.
See also gtoFiniteEnum
.
gfiniteEnumFromThenTo :: (Generic a, GEnum FiniteEnum (Rep a)) => a -> a -> a -> [a] Source #
Generic enumFromThenTo
generated with the FiniteEnum
option.
See also gtoFiniteEnum
.
Bounded
Can also be derived by GHC as part of the standard.
Generic representation of Bounded
types.
Higher-kinded classes
Functor
Can also be derived by GHC (DeriveFunctor
extension).
gfmap :: (Generic1 f, Functor (Rep1 f)) => (a -> b) -> f a -> f b Source #
Generic fmap
.
instanceFunctor
MyTypeF wherefmap
=gfmap
Foldable
Can also be derived by GHC (DeriveFoldable
extension).
gfoldMap :: (Generic1 f, Foldable (Rep1 f), Monoid m) => (a -> m) -> f a -> m Source #
Generic foldMap
.
instanceFoldable
MyTypeF wherefoldMap
=gfoldMap
Traversable
Can also be derived by GHC (DeriveTraversable
extension).
gtraverse :: (Generic1 f, Traversable (Rep1 f), Applicative m) => (a -> m b) -> f a -> m (f b) Source #
Generic traverse
.
instanceTraversable
MyTypeF wheretraverse
=gtraverse
gsequenceA :: (Generic1 f, Traversable (Rep1 f), Applicative m) => f (m a) -> m (f a) Source #
Applicative
gliftA2 :: (Generic1 f, Applicative (Rep1 f)) => (a -> b -> c) -> f a -> f b -> f c Source #
Generic liftA2
.
See also gpure
.
Alternative
galt :: (Generic1 f, Alternative (Rep1 f)) => f a -> f a -> f a Source #
Generic (<|>
).
See also gempty
.
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
.
Show1
gliftShowsPrec :: (Generic1 f, GShow1 (Rep1 f)) => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS Source #
Generic liftShowsPrec
.
Fields wrappers for deriving
A newtype whose instances for simple classes (Eq
, Ord
, Read
, Show
)
use higher-kinded class instances for f
(Eq1
, Ord1
, Read1
, Show1
).
Instances
Show1 f => Show1 (Id1 f) Source # | |
Defined in Generic.Data.Internal.Resolvers Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Id1 f a -> ShowS liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Id1 f a] -> ShowS | |
Read1 f => Read1 (Id1 f) Source # | |
Defined in Generic.Data.Internal.Resolvers Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Id1 f a) liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Id1 f a] liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Id1 f a) liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Id1 f a] | |
Ord1 f => Ord1 (Id1 f) Source # | |
Defined in Generic.Data.Internal.Resolvers Methods liftCompare :: (a -> b -> Ordering) -> Id1 f a -> Id1 f b -> Ordering | |
Eq1 f => Eq1 (Id1 f) Source # | |
Defined in Generic.Data.Internal.Resolvers | |
(Eq1 f, Eq a) => Eq (Id1 f a) Source # | |
(Ord1 f, Ord a) => Ord (Id1 f a) Source # | |
(Read1 f, Read a) => Read (Id1 f a) Source # | |
Defined in Generic.Data.Internal.Resolvers | |
(Show1 f, Show a) => Show (Id1 f a) Source # | |
A newtype with trivial instances, that considers
every value equivalent to every other one,
and shows as just "_"
.
Instances
Show1 Opaque Source # | Shown as |
Defined in Generic.Data.Internal.Resolvers Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Opaque a -> ShowS liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Opaque a] -> ShowS | |
Ord1 Opaque Source # | All equal. |
Defined in Generic.Data.Internal.Resolvers Methods liftCompare :: (a -> b -> Ordering) -> Opaque a -> Opaque b -> Ordering | |
Eq1 Opaque Source # | All equal. |
Defined in Generic.Data.Internal.Resolvers | |
Eq (Opaque a) Source # | All equal. |
Ord (Opaque a) Source # | All equal. |
Defined in Generic.Data.Internal.Resolvers | |
Show (Opaque a) Source # | Shown as |
A higher-kinded version of Opaque
.
Instances
Show1 (Opaque1 f) Source # | Shown as |
Defined in Generic.Data.Internal.Resolvers Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Opaque1 f a -> ShowS liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Opaque1 f a] -> ShowS | |
Ord1 (Opaque1 f) Source # | All equal. |
Defined in Generic.Data.Internal.Resolvers Methods liftCompare :: (a -> b -> Ordering) -> Opaque1 f a -> Opaque1 f b -> Ordering | |
Eq1 (Opaque1 f) Source # | All equal. |
Defined in Generic.Data.Internal.Resolvers | |
Eq (Opaque1 f a) Source # | All equal. |
Ord (Opaque1 f a) Source # | All equal. |
Defined in Generic.Data.Internal.Resolvers | |
Show (Opaque1 f a) Source # | Shown as |
Carriers of generic instances
newtype Generically a Source #
Type with instances derived via Generic
.
Constructors
Generically | |
Fields
|
Instances
newtype FiniteEnumeration a Source #
Type with Enum
instance derived via Generic
with FiniteEnum
option.
Constructors
FiniteEnumeration | |
Fields
|
Instances
newtype Generically1 f a Source #
Type with instances derived via Generic1
.
Constructors
Generically1 | |
Fields
|
Instances
(Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f) Source # | |
Defined in Generic.Data.Internal.Generically Methods fmap :: (a -> b) -> Generically1 f a -> Generically1 f b (<$) :: a -> Generically1 f b -> Generically1 f a | |
(Generic1 f, Applicative (Rep1 f)) => Applicative (Generically1 f) Source # | |
Defined in Generic.Data.Internal.Generically Methods pure :: a -> Generically1 f a (<*>) :: Generically1 f (a -> b) -> Generically1 f a -> Generically1 f b liftA2 :: (a -> b -> c) -> Generically1 f a -> Generically1 f b -> Generically1 f c (*>) :: Generically1 f a -> Generically1 f b -> Generically1 f b (<*) :: Generically1 f a -> Generically1 f b -> Generically1 f a | |
(Generic1 f, Foldable (Rep1 f)) => Foldable (Generically1 f) Source # | |
Defined in Generic.Data.Internal.Generically Methods fold :: Monoid m => Generically1 f m -> m foldMap :: Monoid m => (a -> m) -> Generically1 f a -> m foldMap' :: Monoid m => (a -> m) -> Generically1 f a -> m foldr :: (a -> b -> b) -> b -> Generically1 f a -> b foldr' :: (a -> b -> b) -> b -> Generically1 f a -> b foldl :: (b -> a -> b) -> b -> Generically1 f a -> b foldl' :: (b -> a -> b) -> b -> Generically1 f a -> b foldr1 :: (a -> a -> a) -> Generically1 f a -> a foldl1 :: (a -> a -> a) -> Generically1 f a -> a toList :: Generically1 f a -> [a] null :: Generically1 f a -> Bool length :: Generically1 f a -> Int elem :: Eq a => a -> Generically1 f a -> Bool maximum :: Ord a => Generically1 f a -> a minimum :: Ord a => Generically1 f a -> a sum :: Num a => Generically1 f a -> a product :: Num a => Generically1 f a -> a | |
(Generic1 f, Traversable (Rep1 f)) => Traversable (Generically1 f) Source # | |
Defined in Generic.Data.Internal.Generically Methods traverse :: Applicative f0 => (a -> f0 b) -> Generically1 f a -> f0 (Generically1 f b) sequenceA :: Applicative f0 => Generically1 f (f0 a) -> f0 (Generically1 f a) mapM :: Monad m => (a -> m b) -> Generically1 f a -> m (Generically1 f b) sequence :: Monad m => Generically1 f (m a) -> m (Generically1 f a) | |
(Generic1 f, GShow1 (Rep1 f)) => Show1 (Generically1 f) Source # | |
Defined in Generic.Data.Internal.Generically Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Generically1 f a -> ShowS liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Generically1 f a] -> ShowS | |
(Generic1 f, Ord1 (Rep1 f)) => Ord1 (Generically1 f) Source # | |
Defined in Generic.Data.Internal.Generically Methods liftCompare :: (a -> b -> Ordering) -> Generically1 f a -> Generically1 f b -> Ordering | |
(Generic1 f, Eq1 (Rep1 f)) => Eq1 (Generically1 f) Source # | |
Defined in Generic.Data.Internal.Generically Methods liftEq :: (a -> b -> Bool) -> Generically1 f a -> Generically1 f b -> Bool | |
(Generic1 f, Alternative (Rep1 f)) => Alternative (Generically1 f) Source # | |
Defined in Generic.Data.Internal.Generically Methods empty :: Generically1 f a (<|>) :: Generically1 f a -> Generically1 f a -> Generically1 f a some :: Generically1 f a -> Generically1 f [a] many :: Generically1 f a -> Generically1 f [a] | |
Generic1 f => Generic1 (Generically1 f :: Type -> Type) Source # | |
Defined in Generic.Data.Internal.Generically Associated Types type Rep1 (Generically1 f) :: k -> Type Methods from1 :: forall (a :: k). Generically1 f a -> Rep1 (Generically1 f) a to1 :: forall (a :: k). Rep1 (Generically1 f) a -> Generically1 f a | |
(Generic1 f, Eq1 (Rep1 f), Eq a) => Eq (Generically1 f a) Source # | |
Defined in Generic.Data.Internal.Generically Methods (==) :: Generically1 f a -> Generically1 f a -> Bool (/=) :: Generically1 f a -> Generically1 f a -> Bool | |
(Generic1 f, Ord1 (Rep1 f), Ord a) => Ord (Generically1 f a) Source # | |
Defined in Generic.Data.Internal.Generically Methods compare :: Generically1 f a -> Generically1 f a -> Ordering (<) :: Generically1 f a -> Generically1 f a -> Bool (<=) :: Generically1 f a -> Generically1 f a -> Bool (>) :: Generically1 f a -> Generically1 f a -> Bool (>=) :: Generically1 f a -> Generically1 f a -> Bool max :: Generically1 f a -> Generically1 f a -> Generically1 f a min :: Generically1 f a -> Generically1 f a -> Generically1 f a | |
(Generic1 f, GShow1 (Rep1 f), Show a) => Show (Generically1 f a) Source # | |
Defined in Generic.Data.Internal.Generically Methods showsPrec :: Int -> Generically1 f a -> ShowS show :: Generically1 f a -> String showList :: [Generically1 f a] -> ShowS | |
Generic (f a) => Generic (Generically1 f a) Source # | |
Defined in Generic.Data.Internal.Generically Associated Types type Rep (Generically1 f a) :: Type -> Type Methods from :: Generically1 f a -> Rep (Generically1 f a) x to :: Rep (Generically1 f a) x -> Generically1 f a | |
type Rep1 (Generically1 f :: Type -> Type) Source # | |
Defined in Generic.Data.Internal.Generically type Rep1 (Generically1 f :: Type -> Type) = Rep1 f | |
type Rep (Generically1 f a) Source # | |
Defined in Generic.Data.Internal.Generically type Rep (Generically1 f a) = Rep (f a) |
Newtype
Generic pack/unpack.
class (Generic a, Coercible a (Old a), Newtype' a) => Newtype a Source #
Class of newtypes. There is an instance
if and only if Newtype
aa
is a newtype and an instance of Generic
.
Generic coercions
gcoerce :: (Generic a, Generic b, Coercible (Rep a) (Rep b)) => a -> b Source #
Convert between types with representationally equivalent generic representations.
gcoerceBinop :: (Generic a, Generic b, Coercible (Rep a) (Rep b)) => (a -> a -> a) -> b -> b -> b Source #
Compose gcoerce
with a binary operation.
Accessing metadata
Using TypeApplications
.
Datatype
gdatatypeName :: forall a. (Generic a, GDatatype (Rep a)) => String Source #
Name of the first data constructor in a type as a string.
gdatatypeName
@(Maybe
AnyType) = "Maybe"
gmoduleName :: forall a. (Generic a, GDatatype (Rep a)) => String Source #
Name of the module where the first type constructor is defined.
gmoduleName
@(Maybe
AnyType) = "GHC.Base"
gpackageName :: forall a. (Generic a, GDatatype (Rep a)) => String Source #
Name of the package where the first type constructor is defined.
gpackageName
@(Maybe
AnyType) = "base"
gisNewtype :: forall a. (Generic a, GDatatype (Rep a)) => Bool Source #
True
if the first type constructor is a newtype.
Generic representations that contain datatype metadata.
Minimal complete definition
Instances
Datatype d => GDatatype (M1 D d f :: k -> Type) Source # | |
Defined in Generic.Data.Internal.Meta Methods gDatatypeName :: String Source # gModuleName :: String Source # gPackageName :: String Source # gIsNewtype :: Bool Source # |
Constructor
gconName :: forall a. Constructors a => a -> String Source #
Name of the first constructor in a value.
gconName
(Just
0) = "Just"
gconFixity :: forall a. Constructors a => a -> Fixity Source #
The fixity of the first constructor.
gconFixity
(Just
0) =Prefix
gconFixity
([] :*: id) =Infix
RightAssociative
6
gconIsRecord :: forall a. Constructors a => a -> Bool Source #
True
if the constructor is a record.
gconIsRecord
(Just
0) =False
gconIsRecord
(Sum
0) =True
-- newtypeSum
a = Sum { getSum :: a }
gconNum :: forall a. Constructors a => Int Source #
Number of constructors.
gconNum
@(Maybe
AnyType) = 2
gconIndex :: forall a. Constructors a => a -> Int Source #
class (Generic a, GConstructors (Rep a)) => Constructors a Source #
Constraint synonym for Generic
and GConstructors
.
Instances
(Generic a, GConstructors (Rep a)) => Constructors a Source # | |
Defined in Generic.Data.Internal.Meta |
class GConstructors r Source #
Generic representations that contain constructor metadata.
Minimal complete definition
Instances
(GConstructors f, GConstructors g) => GConstructors (f :+: g :: k -> Type) Source # | |
Defined in Generic.Data.Internal.Meta | |
Constructor c => GConstructors (M1 C c f :: k -> Type) Source # | |
Defined in Generic.Data.Internal.Meta | |
GConstructors f => GConstructors (M1 D c f :: k -> Type) Source # | |
Defined in Generic.Data.Internal.Meta |
Constructor tags
conId :: forall a. Constructors a => a -> ConId a Source #
Identifier of a constructor.
conIdToInt :: forall a. ConId a -> Int Source #
Index of a constructor, given its identifier.
See also gconIndex
.
conIdToString :: forall a. Constructors a => ConId a -> String Source #
Name of a constructor. See also gconName
.
conIdEnum :: forall a. Constructors a => [ConId a] Source #
Using type families
type family MetaOf (f :: * -> *) :: Meta where ... Source #
Meta
field of the M1
type constructor.
Equations
MetaOf (M1 i d f) = d |
type family MetaDataName (m :: Meta) :: Symbol where ... Source #
Name of the data type (MetaData
).
Equations
MetaDataName ('MetaData n _m _p _nt) = n |
type family MetaDataModule (m :: Meta) :: Symbol where ... Source #
Name of the module where the data type is defined (MetaData
)
Equations
MetaDataModule ('MetaData _n m _p _nt) = m |
type family MetaDataPackage (m :: Meta) :: Symbol where ... Source #
Name of the package where the data type is defined (MetaData
)
Equations
MetaDataPackage ('MetaData _n _m p _nt) = p |
type family MetaDataNewtype (m :: Meta) :: Bool where ... Source #
True
if the data type is a newtype (MetaData
).
Equations
MetaDataNewtype ('MetaData _n _m _p nt) = nt |
type family MetaConsName (m :: Meta) :: Symbol where ... Source #
Name of the constructor (MetaCons
).
Equations
MetaConsName ('MetaCons n _f _s) = n |
type family MetaConsFixity (m :: Meta) :: FixityI where ... Source #
Fixity of the constructor (MetaCons
).
Equations
MetaConsFixity ('MetaCons _n f s) = f |
type family MetaConsRecord (m :: Meta) :: Bool where ... Source #
True
for a record constructor (MetaCons
).
Equations
MetaConsRecord ('MetaCons _n _f s) = s |
type family MetaSelNameM (m :: Meta) :: Maybe Symbol where ... Source #
Just
the name of the record field, if it is one (MetaSel
).
Equations
MetaSelNameM ('MetaSel mn _su _ss _ds) = mn |
type family MetaSelName (m :: Meta) :: Symbol where ... Source #
Name of the record field; undefined for non-record fields (MetaSel
).
Equations
MetaSelName ('MetaSel ('Just n) _su _ss _ds) = n |
type family MetaSelUnpack (m :: Meta) :: SourceUnpackedness where ... Source #
Unpackedness annotation of a field (MetaSel
).
Equations
MetaSelUnpack ('MetaSel _mn su _ss _ds) = su |
type family MetaSelSourceStrictness (m :: Meta) :: SourceStrictness where ... Source #
Strictness annotation of a field (MetaSel
).
Equations
MetaSelSourceStrictness ('MetaSel _mn _su ss _ds) = ss |
type family MetaSelStrictness (m :: Meta) :: DecidedStrictness where ... Source #
Inferred strictness of a field (MetaSel
).
Equations
MetaSelStrictness ('MetaSel _mn _su _ss ds) = ds |