License | BSD-style (see the file LICENSE) |
---|---|
Maintainer | sjoerd@w3future.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell98 |
- type family Constraints' (t :: * -> *) (c :: * -> Constraint) :: Constraint
- class ADT' t where
- type CtorCount' t :: Nat
- class Profunctor p => GenericProfunctor p where
- generic :: (ADT t, Constraints t c, GenericProfunctor p) => for c -> (forall s. c s => p s s) -> p t t
- type Constraints t c = Constraints' (Rep t) c
- type ADT t = (Generic t, ADT' (Rep t))
- type CtorCount t = CtorCount' (Rep t)
- type ADTRecord t = (ADT t, 1 ~ CtorCount t)
- type ADTNonEmpty t = (ADT t, 1 <= CtorCount t)
- data For c = For
- ctorIndex :: ADT t => t -> Int
Documentation
type family Constraints' (t :: * -> *) (c :: * -> Constraint) :: Constraint Source #
type Constraints' V1 c Source # | |
type Constraints' U1 c Source # | |
type Constraints' (K1 i a) c Source # | |
type Constraints' ((:+:) f g) c Source # | |
type Constraints' ((:*:) f g) c Source # | |
type Constraints' (M1 i t f) c Source # | |
type CtorCount' t :: Nat Source #
ctorIndex' :: t x -> Int Source #
ctorCount :: proxy t -> Int Source #
p :: (Constraints' t c, GenericProfunctor p) => for c -> (forall s. c s => p s s) -> p (t x) (t x) Source #
class Profunctor p => GenericProfunctor p where Source #
zero :: p (V1 a) (V1 a) Source #
unit :: p (U1 a) (U1 a) Source #
plus :: p (f a) (f' a) -> p (g a) (g' a) -> p ((f :+: g) a) ((f' :+: g') a) Source #
mult :: p (f a) (f' a) -> p (g a) (g' a) -> p ((f :*: g) a) ((f' :*: g') a) Source #
Applicative f => GenericProfunctor (Star f) Source # | |
generic :: (ADT t, Constraints t c, GenericProfunctor p) => for c -> (forall s. c s => p s s) -> p t t Source #
All the above functions have been implemented using this single function,
using different profunctor
s.
type Constraints t c = Constraints' (Rep t) c Source #
Constraints
is a constraint type synonym, containing the constraint requirements for an instance for t
of class c
.
It requires an instance of class c
for each component of t
.
type CtorCount t = CtorCount' (Rep t) Source #
type ADTNonEmpty t = (ADT t, 1 <= CtorCount t) Source #
ADTNonEmpty
is a constraint type synonym. An instance is an ADT
with *at least* one constructor.
Tell the compiler which class we want to use in the traversal. Should be used like this:
(For :: For Show)
Where Show
can be any class.