Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- type SumKind k = (k -> Type) -> (k -> Type) -> k -> Type
- type (~>) f g = forall x. f x -> g x
- absurdZero :: Const Void a -> b
- absurdV1 :: V1 a -> b
- class ConvSum (rep1 :: k -> Type) where
- class ConvProduct (rep1 :: k -> Type) where
- type ToProduct (rep1 :: k -> Type) (end :: k -> Type) :: k -> Type
- convToProduct :: rep1 a -> end a -> ToProduct rep1 end a
- convFromProduct :: ToProduct rep1 end a -> (rep1 a -> end a -> res) -> res
- class ConvField (rep1 :: k -> Type) where
- type ToField (rep1 :: k -> Type) :: k -> Type
- convToField :: rep1 ~> ToField rep1
- convFromField :: ToField rep1 ~> rep1
- data SumTag
- type family CheckSum rep1 where ...
- type BæSum rep1 = BæSum_ (CheckSum rep1) rep1
- type ConvBæSum rep1 = ConvBæSum_ (CheckSum rep1) rep1
- class CheckSum rep1 ~ tag => ConvBæSum_ tag (rep1 :: k -> Type) where
- data ProductTag
- type family CheckProduct rep1 where ...
- type BæProduct rep1 = BæProduct_ (CheckProduct rep1) rep1
- type ConvBæProduct rep1 = ConvBæProduct_ (CheckProduct rep1) rep1
- class tag ~ CheckProduct rep1 => ConvBæProduct_ tag (rep1 :: k -> Type) where
- type BæProduct_ tag (rep1 :: k -> Type) :: k -> Type
- convBæProduct :: rep1 ~> BæProduct rep1
- convHæProduct :: BæProduct rep1 ~> rep1
- type Flatten rep1 = ToSum rep1 (Const Void)
- flatten :: ConvSum rep1 => rep1 ~> Flatten rep1
- nest :: ConvSum rep1 => Flatten rep1 a -> rep1 a
- type family ReplaceSums sums rep1 where ...
- replaceSums :: forall sums rep1. rep1 ~> ReplaceSums sums rep1
- placeSums :: forall sums rep1. ReplaceSums sums rep1 ~> rep1
- newtype NewSums sums f a = NewSums {
- reduce :: f a
- newtype Generically1 f a = Generically1 (f a)
Documentation
type SumKind k = (k -> Type) -> (k -> Type) -> k -> Type Source #
The kind of a lifted binary type constructor.
Sum :: SumKind k Product :: SumKind k (:+:) :: SumKind k (:*:) :: SumKind k
Definition:
type SumKind :: Type -> Type type SumKind k = (k -> Type) -> (k -> Type) -> (k -> Type)
type (~>) f g = forall x. f x -> g x Source #
A polymorphic function / natural transformation.
Used for Applicative homomorphisms (Idiom
):
idiom _
tag :: Idiom tag l r => l ~> r
Definition:
type (~>) :: (k -> Type) -> (k -> Type) -> Type type f ~> g = forall x. f x -> g x
absurdZero :: Const Void a -> b Source #
absurd
for Const Void
.
absurdZero :: Const Void a -> b absurdZero (Const void) = absurd void
class ConvSum (rep1 :: k -> Type) where Source #
The first thing I do is to convert
convToSum :: Proxy end -> rep1 ~> ToSum rep1 end Source #
convToSumSkip :: end ~> ToSum rep1 end Source #
convFromSum :: ToSum rep1 end a -> (rep1 a -> res) -> (end a -> res) -> res Source #
Instances
ConvSum (V1 :: k -> Type) Source # | |
Defined in Generic.Applicative.Internal | |
ConvSum rep1 => ConvSum (D1 meta rep1 :: k -> Type) Source # | |
Defined in Generic.Applicative.Internal convToSum :: forall (end :: k0 -> Type). Proxy end -> D1 meta rep1 ~> ToSum (D1 meta rep1) end Source # convToSumSkip :: forall (end :: k0 -> Type). end ~> ToSum (D1 meta rep1) end Source # convFromSum :: forall end (a :: k0) res. ToSum (D1 meta rep1) end a -> (D1 meta rep1 a -> res) -> (end a -> res) -> res Source # | |
(ConvSum rep1, ConvSum rep1') => ConvSum (rep1 :+: rep1' :: k -> Type) Source # | |
Defined in Generic.Applicative.Internal convToSum :: forall (end :: k0 -> Type). Proxy end -> (rep1 :+: rep1') ~> ToSum (rep1 :+: rep1') end Source # convToSumSkip :: forall (end :: k0 -> Type). end ~> ToSum (rep1 :+: rep1') end Source # convFromSum :: forall end (a :: k0) res. ToSum (rep1 :+: rep1') end a -> ((rep1 :+: rep1') a -> res) -> (end a -> res) -> res Source # | |
ConvProduct rep1 => ConvSum (C1 meta rep1 :: k -> Type) Source # | |
Defined in Generic.Applicative.Internal convToSum :: forall (end :: k0 -> Type). Proxy end -> C1 meta rep1 ~> ToSum (C1 meta rep1) end Source # convToSumSkip :: forall (end :: k0 -> Type). end ~> ToSum (C1 meta rep1) end Source # convFromSum :: forall end (a :: k0) res. ToSum (C1 meta rep1) end a -> (C1 meta rep1 a -> res) -> (end a -> res) -> res Source # |
class ConvProduct (rep1 :: k -> Type) where Source #
convToProduct :: rep1 a -> end a -> ToProduct rep1 end a Source #
convFromProduct :: ToProduct rep1 end a -> (rep1 a -> end a -> res) -> res Source #
Instances
ConvProduct (U1 :: k -> Type) Source # | |
(ConvProduct rep1, ConvProduct rep1') => ConvProduct (rep1 :*: rep1' :: k -> Type) Source # | |
Defined in Generic.Applicative.Internal | |
ConvField rep1 => ConvProduct (S1 meta rep1 :: k -> Type) Source # | |
Defined in Generic.Applicative.Internal |
class ConvField (rep1 :: k -> Type) where Source #
Nothing
convToField :: rep1 ~> ToField rep1 Source #
convFromField :: ToField rep1 ~> rep1 Source #
type ConvBæSum rep1 = ConvBæSum_ (CheckSum rep1) rep1 Source #
class CheckSum rep1 ~ tag => ConvBæSum_ tag (rep1 :: k -> Type) where Source #
Instances
CheckSum rep1 ~ 'NotSum => ConvBæSum_ 'NotSum (rep1 :: k -> Type) Source # | |
(CheckSum (Sum rep1 rep1') ~ 'NormalSum, ConvBæProduct rep1, ConvBæSum rep1') => ConvBæSum_ 'NormalSum (Sum rep1 rep1' :: k -> Type) Source # | |
(ConvBæProduct rep1, CheckSum (Sum rep1 (Const Void :: k -> Type)) ~ 'RightZero, void ~ Void) => ConvBæSum_ 'RightZero (Sum rep1 (Const void :: k -> Type) :: k -> Type) Source # | |
type family CheckProduct rep1 where ... Source #
CheckProduct (Product rep1 (Const ())) = 'RightOne | |
CheckProduct (Product rep1 rep') = 'NormalProduct | |
CheckProduct rep = 'NotProduct |
type BæProduct rep1 = BæProduct_ (CheckProduct rep1) rep1 Source #
type ConvBæProduct rep1 = ConvBæProduct_ (CheckProduct rep1) rep1 Source #
class tag ~ CheckProduct rep1 => ConvBæProduct_ tag (rep1 :: k -> Type) where Source #
type BæProduct_ tag (rep1 :: k -> Type) :: k -> Type Source #
convBæProduct :: rep1 ~> BæProduct rep1 Source #
convHæProduct :: BæProduct rep1 ~> rep1 Source #
Instances
CheckProduct rep1 ~ 'NotProduct => ConvBæProduct_ 'NotProduct (rep1 :: k -> Type) Source # | |
Defined in Generic.Applicative.Internal type BæProduct_ 'NotProduct rep1 :: k -> Type Source # convBæProduct :: rep1 ~> BæProduct rep1 Source # convHæProduct :: BæProduct rep1 ~> rep1 Source # | |
unit ~ () => ConvBæProduct_ 'RightOne (Product rep1 (Const unit :: k -> Type) :: k -> Type) Source # | |
Defined in Generic.Applicative.Internal | |
(CheckProduct (Product rep1 rep1') ~ 'NormalProduct, ConvBæProduct rep1') => ConvBæProduct_ 'NormalProduct (Product rep1 rep1' :: k -> Type) Source # | |
Defined in Generic.Applicative.Internal type BæProduct_ 'NormalProduct (Product rep1 rep1') :: k -> Type Source # |
flatten :: ConvSum rep1 => rep1 ~> Flatten rep1 Source #
Flattens a generic representation.
Afaik GHC is free to nest the generic representation however it
fancies. The representation of data A a = A a a a a
is for
example
@ Rep1 A = (Par1 :+: Par1) :+: (Par1 :+: Par1) -- without metadata
type family ReplaceSums sums rep1 where ... Source #
ReplaceSums (sum ': sums) (Sum rep1 rep1') = rep1 `sum` ReplaceSums sums rep1' | |
ReplaceSums '[] rep1 = rep1 |
replaceSums :: forall sums rep1. rep1 ~> ReplaceSums sums rep1 Source #
This is actually not safe and causes a segfault.
placeSums :: forall sums rep1. ReplaceSums sums rep1 ~> rep1 Source #
newtype Generically1 f a Source #
This exists in versions that don't have Generically1
,
i.e. before base 4.17.0.0.
Generically1 (f a) |