Copyright | (c) Fumiaki Kinoshita 2015 |
---|---|

License | BSD3 |

Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |

Stability | experimental |

Portability | non-portable |

Safe Haskell | Trustworthy |

Language | Haskell2010 |

- data h :* s where
- (<:) :: h x -> (h :* xs) -> h :* (x : xs)
- (<:*) :: forall h x xs. h x -> (h :* xs) -> h :* (x : xs)
- (*++*) :: (h :* xs) -> (h :* ys) -> h :* (xs ++ ys)
- hhead :: (h :* (x : xs)) -> h x
- htail :: (h :* (x : xs)) -> h :* xs
- huncons :: forall h x xs. (h :* (x : xs)) -> (h x, h :* xs)
- hmap :: (forall x. g x -> h x) -> (g :* xs) -> h :* xs
- hmapWithIndex :: forall g h xs. (forall x. Membership xs x -> g x -> h x) -> (g :* xs) -> h :* xs
- htrans :: (forall x. g x -> h (t x)) -> (g :* xs) -> h :* Map t xs
- hzipWith :: (forall x. f x -> g x -> h x) -> (f :* xs) -> (g :* xs) -> h :* xs
- hzipWith3 :: (forall x. f x -> g x -> h x -> i x) -> (f :* xs) -> (g :* xs) -> (h :* xs) -> i :* xs
- hfoldMap :: Monoid a => (forall x. h x -> a) -> (h :* xs) -> a
- htraverse :: Applicative f => (forall x. g x -> f (h x)) -> (g :* xs) -> f (h :* xs)
- htraverseWithIndex :: forall f g h xs. Applicative f => (forall x. Membership xs x -> g x -> f (h x)) -> (g :* xs) -> f (h :* xs)
- hsequence :: Applicative f => (Comp f h :* xs) -> f (h :* xs)
- hcollect :: (Functor f, Generate xs) => (a -> h :* xs) -> f a -> Comp f h :* xs
- hdistribute :: (Functor f, Generate xs) => f (h :* xs) -> Comp f h :* xs
- hlookup :: Membership xs x -> (h :* xs) -> h x
- hindex :: (h :* xs) -> Membership xs x -> h x
- sectorAt :: Functor f => Membership xs x -> (h x -> f (h x)) -> (h :* xs) -> f (h :* xs)
- sector :: (Functor f, x ∈ xs) => (h x -> f (h x)) -> (h :* xs) -> f (h :* xs)
- class Generate xs where
- hgenerate :: Applicative f => (forall x. Membership xs x -> f (h x)) -> f (h :* xs)

- htabulate :: Generate xs => (forall x. Membership xs x -> h x) -> h :* xs
- class Forall c xs where
- hgenerateFor :: Applicative f => proxy c -> (forall x. c x => Membership xs x -> f (h x)) -> f (h :* xs)

- htabulateFor :: Forall c xs => proxy c -> (forall x. c x => Membership xs x -> h x) -> h :* xs

# Basic operations

The type of extensible products.

(:*) :: (k -> *) -> [k] -> *

Functor f => Extensible k f (->) ((:*) k) Source |

huncons :: forall h x xs. (h :* (x : xs)) -> (h x, h :* xs) Source

Split a product to the head and the tail.

hmapWithIndex :: forall g h xs. (forall x. Membership xs x -> g x -> h x) -> (g :* xs) -> h :* xs Source

`hmap`

with `Membership`

s.

htrans :: (forall x. g x -> h (t x)) -> (g :* xs) -> h :* Map t xs Source

Transform every elements in a product, preserving the order.

hzipWith :: (forall x. f x -> g x -> h x) -> (f :* xs) -> (g :* xs) -> h :* xs Source

`zipWith`

for heterogeneous product

hzipWith3 :: (forall x. f x -> g x -> h x -> i x) -> (f :* xs) -> (g :* xs) -> (h :* xs) -> i :* xs Source

`zipWith3`

for heterogeneous product

htraverse :: Applicative f => (forall x. g x -> f (h x)) -> (g :* xs) -> f (h :* xs) Source

Traverse all elements and combine the result sequentially.
```
htraverse (fmap f . g) ≡ fmap (hmap f) . htraverse g
htraverse pure ≡ pure
htraverse (Comp . fmap g . f) ≡ Comp . fmap (htraverse g) . htraverse f
```

htraverseWithIndex :: forall f g h xs. Applicative f => (forall x. Membership xs x -> g x -> f (h x)) -> (g :* xs) -> f (h :* xs) Source

`htraverse`

with `Membership`

s.

hsequence :: Applicative f => (Comp f h :* xs) -> f (h :* xs) Source

`sequence`

analog for extensible products

hcollect :: (Functor f, Generate xs) => (a -> h :* xs) -> f a -> Comp f h :* xs Source

The dual of `htraverse`

hdistribute :: (Functor f, Generate xs) => f (h :* xs) -> Comp f h :* xs Source

The dual of `hsequence`

# Lookup

hlookup :: Membership xs x -> (h :* xs) -> h x Source

*O(log n)* Pick up an elemtnt.

hindex :: (h :* xs) -> Membership xs x -> h x Source

Flipped `hlookup`

sectorAt :: Functor f => Membership xs x -> (h x -> f (h x)) -> (h :* xs) -> f (h :* xs) Source

Deprecated: Use pieceAt

The legacy name for `pieceAt`

sector :: (Functor f, x ∈ xs) => (h x -> f (h x)) -> (h :* xs) -> f (h :* xs) Source

Deprecated: Use piece

The legacy name for `piece`

# Generation

class Generate xs where Source

Given a function that maps types to values, we can "collect" entities all you want.

hgenerate :: Applicative f => (forall x. Membership xs x -> f (h x)) -> f (h :* xs) Source

*O(n)* Generate a product with the given function.

htabulate :: Generate xs => (forall x. Membership xs x -> h x) -> h :* xs Source

class Forall c xs where Source

Guarantees the all elements satisfies the predicate.

hgenerateFor :: Applicative f => proxy c -> (forall x. c x => Membership xs x -> f (h x)) -> f (h :* xs) Source

*O(n)* Analogous to `hgenerate`

, but it also supplies a context `c x`

for every elements in `xs`

.

htabulateFor :: Forall c xs => proxy c -> (forall x. c x => Membership xs x -> h x) -> h :* xs Source

Pure version of `hgenerateFor`

.