Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
.
Generically | |
|
Instances
newtype FiniteEnumeration a Source #
Type with Enum
instance derived via Generic
with FiniteEnum
option.
Instances
(Generic a, GEnum FiniteEnum (Rep a)) => Enum (FiniteEnumeration a) Source # | |
Defined in Generic.Data.Internal.Generically succ :: FiniteEnumeration a -> FiniteEnumeration a # pred :: FiniteEnumeration a -> FiniteEnumeration a # toEnum :: Int -> FiniteEnumeration a # fromEnum :: FiniteEnumeration a -> Int # enumFrom :: FiniteEnumeration a -> [FiniteEnumeration a] # enumFromThen :: FiniteEnumeration a -> FiniteEnumeration a -> [FiniteEnumeration a] # enumFromTo :: FiniteEnumeration a -> FiniteEnumeration a -> [FiniteEnumeration a] # enumFromThenTo :: FiniteEnumeration a -> FiniteEnumeration a -> FiniteEnumeration a -> [FiniteEnumeration a] # | |
Generic a => Generic (FiniteEnumeration a) Source # | |
Defined in Generic.Data.Internal.Generically type Rep (FiniteEnumeration a) :: Type -> Type # from :: FiniteEnumeration a -> Rep (FiniteEnumeration a) x # to :: Rep (FiniteEnumeration a) x -> FiniteEnumeration a # | |
type Rep (FiniteEnumeration a) Source # | |
Defined in Generic.Data.Internal.Generically |
newtype Generically1 f a Source #
Type with instances derived via Generic1
.
Generically1 | |
|
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.
Instances
Generic a => Generic (GenericProduct a) Source # | |
Defined in Generic.Data.Internal.Generically type Rep (GenericProduct a) :: Type -> Type # 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 (<>) :: 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 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 |