Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data label := value = KnownSymbol label => (FldProxy label) := !value
- data Rec lts
- rnil :: Rec '[]
- rcons :: forall l t lts s. (RecSize lts ~ s, KnownNat s) => (l := t) -> Rec lts -> Rec ((l := t) ': lts)
- (&) :: forall l t lts s. (RecSize lts ~ s, KnownNat s) => (l := t) -> Rec lts -> Rec ((l := t) ': lts)
- type Has l lts idx s v = (RecTyIdxH 0 l lts ~ idx, RecIdxTyH idx 0 lts ~ v, KnownNat idx, RecSize lts ~ s, KnownNat s)
- get :: forall l v lts idx s. Has l lts idx s v => FldProxy l -> Rec lts -> v
- (&.) :: forall l v lts idx s. Has l lts idx s v => Rec lts -> FldProxy l -> v
- set :: forall l v lts idx s. Has l lts idx s v => FldProxy l -> v -> Rec lts -> Rec lts
- class SetPath k x where
- data SPath t where
- (&:) :: FldProxy l -> SPath ls -> SPath (l ': ls)
- snil :: SPath '[]
- reflectRec :: forall c r lts. RecApply lts lts c => Proxy c -> (forall a. c a => String -> a -> r) -> Rec lts -> [r]
- class RecApply rts lts c where
- type family RecTyIdxH (i :: Nat) (l :: Symbol) (lts :: [*]) :: Nat where ...
- type family RecIdxTyH (i :: Nat) (r :: Nat) (lts :: [*]) :: * where ...
- showRec :: forall lts. RecApply lts lts Show => Rec lts -> [(String, String)]
- class RecKeys lts where
- class RecEq rts lts where
- recToValue :: forall lts. RecApply lts lts ToJSON => Rec lts -> Value
- recToEncoding :: forall lts. RecApply lts lts ToJSON => Rec lts -> Encoding
- recJsonParser :: forall lts s. (RecSize lts ~ s, KnownNat s, RecJsonParse lts) => Value -> Parser (Rec lts)
- class RecJsonParse lts where
- class RecNfData lts rts where
- type family RecSize (lts :: [*]) :: Nat where ...
- type family RemoveAccessTo (l :: Symbol) (lts :: [*]) :: [*] where ...
- data FldProxy t = FldProxy
- type family RecDeepTy (ls :: [Symbol]) (lts :: k) :: * where ...
Basics
data label := value infix 6 Source #
Field named l
labels value of type t
adapted from the awesome labels package.
Example: (#name := "Chris") :: ("name" := String)
KnownSymbol label => (FldProxy label) := !value infix 6 |
(RecEq rts (RemoveAccessTo l lts), Has l rts idx s v, Eq v) => RecEq rts ((:) * ((:=) l t) lts) Source # | |
(KnownSymbol l, RecApply rts (RemoveAccessTo l lts) c, Has l rts idx s v, c v) => RecApply rts ((:) * ((:=) l t) lts) c Source # | |
Eq value => Eq ((:=) label value) Source # | |
Ord value => Ord ((:=) label value) Source # | |
Show t => Show ((:=) l t) Source # | |
(KnownSymbol l, FromJSON t, RecJsonParse lts, (~) Nat (RecSize lts) s, KnownNat s) => RecJsonParse ((:) * ((:=) l t) lts) Source # | |
(KnownSymbol l, RecKeys lts) => RecKeys ((:) * ((:=) l t) lts) Source # | |
(Has l rts idx s v, NFData v, RecNfData (RemoveAccessTo l lts) rts) => RecNfData ((:) * ((:=) l t) lts) rts Source # | |
type RecKeysT ((:) * ((:=) l t) lts) Source # | |
The core record type.
RecEq lts lts => Eq (Rec lts) Source # | |
RecApply lts lts Show => Show (Rec lts) Source # | |
RecApply lts lts ToJSON => ToJSON (Rec lts) Source # | |
((~) Nat (RecSize lts) s, KnownNat s, RecJsonParse lts) => FromJSON (Rec lts) Source # | |
RecNfData lts lts => NFData (Rec lts) Source # | |
(SetPath more v, Has l lts idx s v, (~) * (RecDeepTy * ((:) Symbol l more) (Rec lts)) (RecDeepTy * more v)) => SetPath ((:) Symbol l more) (Rec lts) Source # | |
rcons :: forall l t lts s. (RecSize lts ~ s, KnownNat s) => (l := t) -> Rec lts -> Rec ((l := t) ': lts) Source #
Prepend a record entry to a record Rec
(&) :: forall l t lts s. (RecSize lts ~ s, KnownNat s) => (l := t) -> Rec lts -> Rec ((l := t) ': lts) infixr 5 Source #
Alias for rcons
type Has l lts idx s v = (RecTyIdxH 0 l lts ~ idx, RecIdxTyH idx 0 lts ~ v, KnownNat idx, RecSize lts ~ s, KnownNat s) Source #
State that a record contains a label. Leave idx an s free variables, used internally
get :: forall l v lts idx s. Has l lts idx s v => FldProxy l -> Rec lts -> v Source #
Get an existing record field
(&.) :: forall l v lts idx s. Has l lts idx s v => Rec lts -> FldProxy l -> v infixl 3 Source #
Alias for get
set :: forall l v lts idx s. Has l lts idx s v => FldProxy l -> v -> Rec lts -> Rec lts Source #
Update an existing record field
Path to the key that should be updated
Reflection
reflectRec :: forall c r lts. RecApply lts lts c => Proxy c -> (forall a. c a => String -> a -> r) -> Rec lts -> [r] Source #
Apply a function to each key element pair for a record
class RecApply rts lts c where Source #
Machinery needed to implement reflectRec
Machinery
showRec :: forall lts. RecApply lts lts Show => Rec lts -> [(String, String)] Source #
Convert all elements of a record to a String
recJsonParser :: forall lts s. (RecSize lts ~ s, KnownNat s, RecJsonParse lts) => Value -> Parser (Rec lts) Source #
class RecJsonParse lts where Source #
Machinery to implement parseJSON
RecJsonParse ([] *) Source # | |
(KnownSymbol l, FromJSON t, RecJsonParse lts, (~) Nat (RecSize lts) s, KnownNat s) => RecJsonParse ((:) * ((:=) l t) lts) Source # | |
type family RemoveAccessTo (l :: Symbol) (lts :: [*]) :: [*] where ... Source #
RemoveAccessTo l ((l := t) ': lts) = RemoveAccessTo l lts | |
RemoveAccessTo q ((l := t) ': lts) = (l := t) ': RemoveAccessTo l lts | |
RemoveAccessTo q '[] = '[] |