Copyright | (c) Fumiaki Kinoshita 2015 |
---|---|
License | BSD3 |
Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Flexible records with well-typed fields. Example: https://github.com/fumieval/extensible/blob/master/examples/records.hs
- module Data.Extensible.Inclusion
- type Record = (:*) Field
- (<:) :: h x -> (h :* xs) -> h :* (x : xs)
- (<:*) :: forall h x xs. h x -> (h :* xs) -> h :* (x : xs)
- data h :* s where
- (@=) :: FieldName k -> v -> Field (k :> v)
- (<@=>) :: Functor f => FieldName k -> f v -> Comp f Field (k :> v)
- mkField :: String -> DecsQ
- data Field kv where
- getField :: Field (k :> v) -> v
- type FieldLens k = forall f p xs v. (Functor f, Labelable k p, Associate k v xs) => p v (f v) -> Record xs -> f (Record xs)
- type FieldName k = forall v. LabelPhantom k v (Proxy v) -> Record `[k :> v]` -> Proxy (Record `[k :> v]`)
- class Labelable s p where
- unlabel :: proxy s -> p a b -> a -> b
- data LabelPhantom s a b
Documentation
module Data.Extensible.Inclusion
The type of extensible products.
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) |
The type of fields.
type FieldLens k = forall f p xs v. (Functor f, Labelable k p, Associate k v xs) => p v (f v) -> Record xs -> f (Record xs) Source
type FieldName k = forall v. LabelPhantom k v (Proxy v) -> Record `[k :> v]` -> Proxy (Record `[k :> v]`) Source
When you see this type as an argument, it expects a FieldLens
.
This type is used to resolve the name of the field internally.
Internal
class Labelable s p where Source
An internal class to characterize FieldLens
Labelable k s (->) | |
(~) k s t => Labelable k s (LabelPhantom k * * t) |
data LabelPhantom s a b Source
A ghostly type which spells the field name
(~) k s t => Labelable k s (LabelPhantom k * * t) |