Safe Haskell | None |
---|---|

Language | Haskell2010 |

Commonly used `Rec`

instantiations.

## Synopsis

- type (:::) a b = '(a, b)
- data ElField (field :: (Symbol, *)) where
- Field :: KnownSymbol s => !t -> ElField '(s, t)

- type FieldRec = Rec ElField
- type AFieldRec ts = ARec ElField ts
- type HList = Rec Identity
- type LazyHList = Rec Thunk
- getField :: ElField '(s, t) -> t
- getLabel :: forall s t. ElField '(s, t) -> String
- fieldMap :: (a -> b) -> ElField '(s, a) -> ElField '(s, b)
- rfield :: Functor f => (a -> f b) -> ElField '(s, a) -> f (ElField '(s, b))
- (=:) :: KnownSymbol l => Label (l :: Symbol) -> (v :: *) -> ElField (l ::: v)
- rgetf :: forall l f v record us. HasField record l us v => Label l -> record f us -> f (l ::: v)
- rvalf :: HasField record l us v => Label l -> record ElField us -> v
- rputf :: forall l v record us. (HasField record l us v, KnownSymbol l) => Label l -> v -> record ElField us -> record ElField us
- rlensf' :: forall l v record g f us. (Functor g, HasField record l us v) => Label l -> (f (l ::: v) -> g (f (l ::: v))) -> record f us -> g (record f us)
- rlensf :: forall l v record g f us. (Functor g, HasField record l us v) => Label l -> (v -> g v) -> record ElField us -> g (record ElField us)
- (=:=) :: KnownSymbol s => proxy '(s, a) -> a -> FieldRec '['(s, a)]
- data SField (field :: k) = SField
- type family FieldType l fs where ...
- type HasField record l fs v = (RecElem record (l ::: v) fs (RIndex (l ::: v) fs), FieldType l fs ~ v)
- data Label (a :: Symbol) = Label
- class (KnownSymbol (Fst a), a ~ '(Fst a, Snd a)) => KnownField a
- type AllFields fs = (AllConstrained KnownField fs, RecApplicative fs)
- rmapf :: AllFields fs => (forall a. KnownField a => f a -> g a) -> Rec f fs -> Rec g fs
- rpuref :: AllFields fs => (forall a. KnownField a => f a) -> Rec f fs
- (<<$$>>) :: AllFields fs => (forall a. KnownField a => f a -> g a) -> Rec f fs -> Rec g fs
- rlabels :: AllFields fs => Rec (Const String) fs

# Documentation

data ElField (field :: (Symbol, *)) where Source #

Field :: KnownSymbol s => !t -> ElField '(s, t) |

## Instances

Eq t => Eq (ElField ((,) s t)) Source # | |

Ord t => Ord (ElField ((,) s t)) Source # | |

Defined in Data.Vinyl.Derived compare :: ElField (s, t) -> ElField (s, t) -> Ordering # (<) :: ElField (s, t) -> ElField (s, t) -> Bool # (<=) :: ElField (s, t) -> ElField (s, t) -> Bool # (>) :: ElField (s, t) -> ElField (s, t) -> Bool # (>=) :: ElField (s, t) -> ElField (s, t) -> Bool # | |

Show t => Show (ElField ((,) s t)) Source # | |

(KnownSymbol s, Storable t) => Storable (ElField ((,) s t)) Source # | |

Defined in Data.Vinyl.Derived sizeOf :: ElField (s, t) -> Int # alignment :: ElField (s, t) -> Int # peekElemOff :: Ptr (ElField (s, t)) -> Int -> IO (ElField (s, t)) # pokeElemOff :: Ptr (ElField (s, t)) -> Int -> ElField (s, t) -> IO () # peekByteOff :: Ptr b -> Int -> IO (ElField (s, t)) # pokeByteOff :: Ptr b -> Int -> ElField (s, t) -> IO () # |

type AFieldRec ts = ARec ElField ts Source #

An `ARec`

of named fields to provide constant-time field access.

type HList = Rec Identity Source #

Heterogeneous list whose elements are evaluated during list construction.

type LazyHList = Rec Thunk Source #

Heterogeneous list whose elements are left as-is during list
construction (cf. `HList`

).

fieldMap :: (a -> b) -> ElField '(s, a) -> ElField '(s, b) Source #

`ElField`

is isomorphic to a functor something like ```
Compose
ElField ('(,) s)
```

.

rfield :: Functor f => (a -> f b) -> ElField '(s, a) -> f (ElField '(s, b)) Source #

Lens for an `ElField'`

s data payload.

(=:) :: KnownSymbol l => Label (l :: Symbol) -> (v :: *) -> ElField (l ::: v) infix 8 Source #

Operator for creating an `ElField`

. With the `-XOverloadedLabels`

extension, this permits usage such as, `#foo =: 23`

to produce a
value of type `ElField ("foo" ::: Int)`

.

rgetf :: forall l f v record us. HasField record l us v => Label l -> record f us -> f (l ::: v) Source #

Get a named field from a record.

rvalf :: HasField record l us v => Label l -> record ElField us -> v Source #

Get the value associated with a named field from a record.

rputf :: forall l v record us. (HasField record l us v, KnownSymbol l) => Label l -> v -> record ElField us -> record ElField us Source #

Set a named field. `rputf #foo 23`

sets the field named `#foo`

to
`23`

.

rlensf' :: forall l v record g f us. (Functor g, HasField record l us v) => Label l -> (f (l ::: v) -> g (f (l ::: v))) -> record f us -> g (record f us) Source #

rlensf :: forall l v record g f us. (Functor g, HasField record l us v) => Label l -> (v -> g v) -> record ElField us -> g (record ElField us) Source #

(=:=) :: KnownSymbol s => proxy '(s, a) -> a -> FieldRec '['(s, a)] Source #

Shorthand for a `FieldRec`

with a single field.

data SField (field :: k) Source #

A proxy for field types.

type HasField record l fs v = (RecElem record (l ::: v) fs (RIndex (l ::: v) fs), FieldType l fs ~ v) Source #

Constraint that a label is associated with a particular type in a record.

data Label (a :: Symbol) Source #

Proxy for label type

class (KnownSymbol (Fst a), a ~ '(Fst a, Snd a)) => KnownField a Source #

## Instances

KnownSymbol l => KnownField (l ::: v :: (Symbol, k)) Source # | |

Defined in Data.Vinyl.Derived |

type AllFields fs = (AllConstrained KnownField fs, RecApplicative fs) Source #

(<<$$>>) :: AllFields fs => (forall a. KnownField a => f a -> g a) -> Rec f fs -> Rec g fs Source #

Operator synonym for `rmapf`

.