| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Generic.Data.Internal.Generically
Description
Newtypes with instances implemented using generic combinators.
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
- newtype Generically a = Generically {
- unGenerically :: a
- newtype FiniteEnumeration a = FiniteEnumeration {
- unFiniteEnumeration :: a
- newtype Generically1 f a = Generically1 {
- unGenerically1 :: f a
- newtype GenericProduct a = GenericProduct {
- unGenericProduct :: a
Documentation
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
newtype GenericProduct a Source #
Product type with generic instances of Semigroup and Monoid.
This is similar to Generically in most cases, but
GenericProduct also works for types T with deriving
via , where GenericProduct UU is a generic product type coercible to,
but distinct from T. In particular, U may not have an instance of
Semigroup, which Generically requires.
Example
>>>:set -XDeriveGeneric -XDerivingVia>>>data Point a = Point a a deriving Generic>>>:{newtype Vector a = Vector (Point a) deriving (Semigroup, Monoid) via GenericProduct (Point (Sum a)) :}
If it were via instead, then
Generically (Point (Sum a))Vector's mappend (the Monoid method) would be defined as Point's
( (the <>)Semigroup method), which might not exist, or might not be
equivalent to Vector's generic Semigroup instance, which would be
unlawful.
Constructors
| GenericProduct | |
Fields
| |
Instances
| Generic a => Generic (GenericProduct a) Source # | |
Defined in Generic.Data.Internal.Generically Associated Types type Rep (GenericProduct a) :: Type -> Type # Methods from :: GenericProduct a -> Rep (GenericProduct a) x # to :: Rep (GenericProduct a) x -> GenericProduct a # | |
| (AssertNoSum Semigroup a, Generic a, Semigroup (Rep a ())) => Semigroup (GenericProduct a) Source # | |
Defined in Generic.Data.Internal.Generically Methods (<>) :: GenericProduct a -> GenericProduct a -> GenericProduct a # sconcat :: NonEmpty (GenericProduct a) -> GenericProduct a # stimes :: Integral b => b -> GenericProduct a -> GenericProduct a # | |
| (AssertNoSum Semigroup a, Generic a, Monoid (Rep a ())) => Monoid (GenericProduct a) Source # | |
Defined in Generic.Data.Internal.Generically Methods mempty :: GenericProduct a # mappend :: GenericProduct a -> GenericProduct a -> GenericProduct a # mconcat :: [GenericProduct a] -> GenericProduct a # | |
| type Rep (GenericProduct a) Source # | |
Defined in Generic.Data.Internal.Generically | |