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

License | BSD3 |

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

Stability | experimental |

Portability | MPTCs |

Safe Haskell | Safe |

Language | Haskell2010 |

- class (Functor f, Profunctor p) => Extensible f p t where
- pieceAt :: Membership xs x -> Optic' p f (t h xs) (h x)

- piece :: (x ∈ xs, Extensible f p t) => Optic' p f (t h xs) (h x)
- pieceAssoc :: (Associate k v xs, Extensible f p t) => Optic' p f (t h xs) (h (k :> v))
- itemAt :: (Wrapper h, Extensible f p t) => Membership xs x -> Optic' p f (t h xs) (Repr h x)
- item :: (Wrapper h, Extensible f p t, x ∈ xs) => proxy x -> Optic' p f (t h xs) (Repr h x)
- itemAssoc :: (Wrapper h, Extensible f p t, Associate k v xs) => proxy k -> Optic' p f (t h xs) (Repr h (k :> v))
- data Membership xs x
- mkMembership :: Int -> Q Exp
- class Member xs x where
- membership :: Membership xs x

- remember :: forall xs x r. Membership xs x -> (Member xs x => r) -> r
- type (∈) x xs = Member xs x
- type family FindType x xs :: [Nat]
- data Assoc k v = k :> v
- class Associate k v xs | k xs -> v where
- association :: Membership xs (k :> v)

- type family FindAssoc key xs
- type family Elaborate key xs :: Elaborated k v
- data Elaborated k v

# Class

class (Functor f, Profunctor p) => Extensible f p t where Source

This class allows us to use `pieceAt`

for both sums and products.

pieceAt :: Membership xs x -> Optic' p f (t h xs) (h x) Source

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

(Applicative f, Choice p) => Extensible k f p ((:|) k) Source | |

(Functor f, Profunctor p) => Extensible k f p (Inextensible k) Source |

piece :: (x ∈ xs, Extensible f p t) => Optic' p f (t h xs) (h x) Source

Accessor for an element.

pieceAssoc :: (Associate k v xs, Extensible f p t) => Optic' p f (t h xs) (h (k :> v)) Source

Like `piece`

, but reckon membership from its key.

itemAt :: (Wrapper h, Extensible f p t) => Membership xs x -> Optic' p f (t h xs) (Repr h x) Source

itemAssoc :: (Wrapper h, Extensible f p t, Associate k v xs) => proxy k -> Optic' p f (t h xs) (Repr h (k :> v)) Source

# Membership

data Membership xs x Source

The position of `x`

in the type level set `xs`

.

Eq (Membership k xs x) Source | |

Ord (Membership k xs x) Source | |

Show (Membership k xs x) Source |

mkMembership :: Int -> Q Exp Source

Generates a `Membership`

that corresponds to the given ordinal (0-origin).

# Member

class Member xs x where Source

membership :: Membership xs x Source

remember :: forall xs x r. Membership xs x -> (Member xs x => r) -> r Source

Remember that `Member xs x`

from `Membership`

.

# Association

The kind of key-value pairs

k :> v infix 0 |

class Associate k v xs | k xs -> v where Source

is essentially identical to `Associate`

k v xs`(k :> v) ∈ xs`

, but the type `v`

is inferred from `k`

and `xs`

.

association :: Membership xs (k :> v) Source

# Sugar

type family Elaborate key xs :: Elaborated k v Source

data Elaborated k v Source