Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class Pigeonhole f where
- type PigeonholeSize f :: Nat
- from :: f x -> Vec (PigeonholeSize f) x
- to :: Vec (PigeonholeSize f) x -> f x
- gindex :: (Generic i, GFrom i, Generic1 f, GFrom f, GEnumSize i ~ GPigeonholeSize f, InlineInduction (GPigeonholeSize f)) => f a -> i -> a
- gtabulate :: (Generic i, GTo i, Generic1 f, GTo f, GEnumSize i ~ GPigeonholeSize f, InlineInduction (GPigeonholeSize f)) => (i -> a) -> f a
- gix :: (Generic i, GFrom i, Generic1 t, GTo t, GFrom t, GEnumSize i ~ GPigeonholeSize t, InlineInduction (GPigeonholeSize t), Functor f) => i -> (a -> f a) -> t a -> f (t a)
- gtraverse :: (Generic1 t, GFrom t, GTo t, InlineInduction (GPigeonholeSize t), Applicative f) => (a -> f b) -> t a -> f (t b)
- gitraverse :: (Generic i, GTo i, Generic1 t, GFrom t, GTo t, GEnumSize i ~ GPigeonholeSize t, InlineInduction (GPigeonholeSize t), Applicative f) => (i -> a -> f b) -> t a -> f (t b)
- gfrom :: (Generic1 c, GFrom c) => c a -> Vec (GPigeonholeSize c) a
- type GFrom c = GFromRep1 (Rep1 c)
- gto :: forall c a. (Generic1 c, GTo c) => Vec (GPigeonholeSize c) a -> c a
- type GTo c = GToRep1 (Rep1 c)
- type GPigeonholeSize c = PigeonholeSizeRep (Rep1 c) Nat0
Documentation
class Pigeonhole f where Source #
Generic pigeonholes.
Examples:
>>>
from (Identity 'a')
'a' ::: VNil
>>>
data Values a = Values a a a deriving (Generic1)
>>>
instance Pigeonhole Values
>>>
from (Values 1 2 3)
1 ::: 2 ::: 3 ::: VNil
Nothing
type PigeonholeSize f :: Nat Source #
The size of a pigeonhole
from :: f x -> Vec (PigeonholeSize f) x Source #
Converts a value to vector
from :: (Generic1 f, GFrom f, PigeonholeSize f ~ GPigeonholeSize f) => f x -> Vec (PigeonholeSize f) x Source #
Converts a value to vector
to :: Vec (PigeonholeSize f) x -> f x Source #
Converts back from vector.
to :: (Generic1 f, GTo f, PigeonholeSize f ~ GPigeonholeSize f) => Vec (PigeonholeSize f) x -> f x Source #
Converts back from vector.
Instances
Pigeonhole Identity Source # |
|
Defined in Data.Vec.DataFamily.SpineStrict.Pigeonhole type PigeonholeSize Identity :: Nat Source # | |
Pigeonhole (Proxy :: Type -> Type) Source # |
|
Defined in Data.Vec.DataFamily.SpineStrict.Pigeonhole type PigeonholeSize Proxy :: Nat Source # | |
(Pigeonhole f, Pigeonhole g, InlineInduction (PigeonholeSize f)) => Pigeonhole (Product f g) Source # |
|
Defined in Data.Vec.DataFamily.SpineStrict.Pigeonhole type PigeonholeSize (Product f g) :: Nat Source # |
Representable
gindex :: (Generic i, GFrom i, Generic1 f, GFrom f, GEnumSize i ~ GPigeonholeSize f, InlineInduction (GPigeonholeSize f)) => f a -> i -> a Source #
Index.
>>>
gindex (Identity 'y') (Proxy :: Proxy Int)
'y'
>>>
data Key = Key1 | Key2 | Key3 deriving (Generic)
>>>
data Values a = Values a a a deriving (Generic1)
>>>
gindex (Values 'a' 'b' 'c') Key2
'b'
gtabulate :: (Generic i, GTo i, Generic1 f, GTo f, GEnumSize i ~ GPigeonholeSize f, InlineInduction (GPigeonholeSize f)) => (i -> a) -> f a Source #
Tabulate.
>>>
tabulate (\() -> 'x') :: Identity Char
Identity 'x'
>>>
tabulate absurd :: Proxy Integer
Proxy
>>>
tabulate absurd :: Proxy Integer
Proxy
gix :: (Generic i, GFrom i, Generic1 t, GTo t, GFrom t, GEnumSize i ~ GPigeonholeSize t, InlineInduction (GPigeonholeSize t), Functor f) => i -> (a -> f a) -> t a -> f (t a) Source #
A lens. i -> Lens' (t a) a
>>>
view (gix ()) (Identity 'x')
'x'
>>>
over (gix ()) toUpper (Identity 'x')
Identity 'X'
Traversable with index
gtraverse :: (Generic1 t, GFrom t, GTo t, InlineInduction (GPigeonholeSize t), Applicative f) => (a -> f b) -> t a -> f (t b) Source #
Generic traverse.
Don't use, rather use DeriveTraversable
gitraverse :: (Generic i, GTo i, Generic1 t, GFrom t, GTo t, GEnumSize i ~ GPigeonholeSize t, InlineInduction (GPigeonholeSize t), Applicative f) => (i -> a -> f b) -> t a -> f (t b) Source #
Traverse with index.
>>>
data Key = Key1 | Key2 | Key3 deriving (Show, Generic)
>>>
data Values a = Values a a a deriving (Generic1)
>>>
gitraverse (\i a -> Const [(i :: Key, a)]) (Values 'a' 'b' 'c')
Const [(Key1,'a'),(Key2,'b'),(Key3,'c')]
Generic implementation
gto :: forall c a. (Generic1 c, GTo c) => Vec (GPigeonholeSize c) a -> c a Source #
Generic version of to
.
type GPigeonholeSize c = PigeonholeSizeRep (Rep1 c) Nat0 Source #
Compute the size from the type.