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

License | BSD3 |

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

Stability | experimental |

Portability | non-portable |

Safe Haskell | None |

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
- 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. h x -> f (h x)) -> (h :* xs) -> f (h :* xs)
- htabulate :: forall g h xs. (forall x. Membership xs x -> g x -> h x) -> (g :* xs) -> h :* xs
- hlookup :: Membership xs x -> (h :* xs) -> h x
- sector :: forall h x xs. x ∈ xs => Lens' (h :* xs) (h x)
- sectorAt :: forall f h x xs. Functor f => Membership xs x -> (h x -> f (h x)) -> (h :* xs) -> f (h :* xs)
- class Generate xs where
- generateA :: Applicative f => (forall x. Membership xs x -> f (h x)) -> f (h :* xs)

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

- generateFor :: Forall c xs => proxy c -> (forall x. c x => Membership xs x -> h x) -> h :* xs
- fromHList :: HList h xs -> h :* xs
- toHList :: (h :* xs) -> HList h xs

# Basic operations

The extensible product type

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

WrapForall k * Eq h xs => Eq ((:*) k h xs) | |

(Eq ((:*) k h xs), WrapForall k * Ord h xs) => Ord ((:*) k h xs) | |

WrapForall k * Show h xs => Show ((:*) k h xs) | |

WrapForall k * Monoid h xs => Monoid ((:*) k h xs) | |

WrapForall k * Binary h xs => Binary ((:*) k h xs) |

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

Split a product to the head and the tail.

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

Transform every elements in a product, preserving the order.

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. h x -> f (h x)) -> (h :* xs) -> f (h :* xs) Source

Traverse all elements.

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

`hmap`

with its indices.

# Lookup

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

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

sector :: forall h x xs. x ∈ xs => Lens' (h :* xs) (h x) Source

*O(log n)* A lens for a specific element.

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

*O(log n)* A lens for a value in a known position.

# Generation

class Generate xs where Source

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

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

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

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

Pure version of `generateA`

.

class Forall c xs where Source

Guarantees the all elements satisfies the predicate.

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

*O(n)* Analogous to `generate`

, but it also supplies a context `c x`

for every elements in `xs`

.

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

Pure version of `generateForA`

.