schematic-0.3.2.0: JSON-biased spec and validation tool

Safe HaskellNone
LanguageHaskell2010

Data.Schematic.Lens

Synopsis

Documentation

type family FIndex (r :: Symbol) (rs :: [(Symbol, Schema)]) :: Nat where ... Source #

A partial relation that gives the index of a value in a list.

Equations

FIndex r ('(r, s) ': rs) = Z 
FIndex r (s ': rs) = S (FIndex r rs) 

class i ~ FIndex fn rs => FElem (fn :: Symbol) (rs :: [(Symbol, Schema)]) (i :: Nat) where Source #

Minimal complete definition

flens, fget, fput

Associated Types

type ByField fn rs i :: Schema Source #

Methods

flens :: Functor g => proxy fn -> (FieldRepr '(fn, ByField fn rs i) -> g (FieldRepr '(fn, ByField fn rs i))) -> Rec FieldRepr rs -> g (Rec FieldRepr rs) Source #

fget :: proxy fn -> Rec FieldRepr rs -> FieldRepr '(fn, ByField fn rs i) Source #

For Vinyl users who are not using the lens package, we provide a getter.

fput :: FieldRepr '(fn, ByField fn rs i) -> Rec FieldRepr rs -> Rec FieldRepr rs Source #

For Vinyl users who are not using the lens package, we also provide a setter. In general, it will be unambiguous what field is being written to, and so we do not take a proxy argument here.

Instances

FElem fn ((:) (Symbol, Schema) ((,) Symbol Schema fn r) rs) Z Source # 

Associated Types

type ByField (fn :: Symbol) (((Symbol, Schema) ': (Symbol, Schema) fn r) rs :: [(Symbol, Schema)]) (Z :: Nat) :: Schema Source #

Methods

flens :: Functor g => proxy fn -> (FieldRepr ((Symbol, Schema) fn (ByField fn (((Symbol, Schema) ': (Symbol, Schema) fn r) rs) Z)) -> g (FieldRepr ((Symbol, Schema) fn (ByField fn (((Symbol, Schema) ': (Symbol, Schema) fn r) rs) Z)))) -> Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': (Symbol, Schema) fn r) rs) -> g (Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': (Symbol, Schema) fn r) rs)) Source #

fget :: proxy fn -> Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': (Symbol, Schema) fn r) rs) -> FieldRepr ((Symbol, Schema) fn (ByField fn (((Symbol, Schema) ': (Symbol, Schema) fn r) rs) Z)) Source #

fput :: FieldRepr ((Symbol, Schema) fn (ByField fn (((Symbol, Schema) ': (Symbol, Schema) fn r) rs) Z)) -> Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': (Symbol, Schema) fn r) rs) -> Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': (Symbol, Schema) fn r) rs) Source #

((~) Nat (FIndex r ((:) (Symbol, Schema) s rs)) (S i), FElem r rs i) => FElem r ((:) (Symbol, Schema) s rs) (S i) Source # 

Associated Types

type ByField (r :: Symbol) (((Symbol, Schema) ': s) rs :: [(Symbol, Schema)]) (S i :: Nat) :: Schema Source #

Methods

flens :: Functor g => proxy r -> (FieldRepr ((Symbol, Schema) r (ByField r (((Symbol, Schema) ': s) rs) (S i))) -> g (FieldRepr ((Symbol, Schema) r (ByField r (((Symbol, Schema) ': s) rs) (S i))))) -> Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': s) rs) -> g (Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': s) rs)) Source #

fget :: proxy r -> Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': s) rs) -> FieldRepr ((Symbol, Schema) r (ByField r (((Symbol, Schema) ': s) rs) (S i))) Source #

fput :: FieldRepr ((Symbol, Schema) r (ByField r (((Symbol, Schema) ': s) rs) (S i))) -> Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': s) rs) -> Rec (Symbol, Schema) FieldRepr (((Symbol, Schema) ': s) rs) Source #

type family FImage (rs :: [(Symbol, Schema)]) (ss :: [(Symbol, Schema)]) :: [Nat] where ... Source #

A partial relation that gives the indices of a sublist in a larger list.

Equations

FImage '[] ss = '[] 
FImage ('(fn, s) ': rs) ss = FIndex fn ss ': FImage rs ss 

class is ~ FImage rs ss => FSubset (rs :: [(Symbol, Schema)]) (ss :: [(Symbol, Schema)]) is where Source #

Minimal complete definition

fsubset

Methods

fsubset :: Functor g => (Rec FieldRepr rs -> g (Rec FieldRepr rs)) -> Rec FieldRepr ss -> g (Rec FieldRepr ss) Source #

This is a lens into a slice of the larger record. Morally, we have:

fsubset :: Lens' (Rec FieldRepr ss) (Rec FieldRepr rs)

fcast :: Rec FieldRepr ss -> Rec FieldRepr rs Source #

The getter of the fsubset lens is fcast, which takes a larger record to a smaller one by forgetting fields.

freplace :: Rec FieldRepr rs -> Rec FieldRepr ss -> Rec FieldRepr ss Source #

The setter of the fsubset lens is freplace, which allows a slice of a record to be replaced with different values.

Instances

obj :: SingI fields => Iso' (JsonRepr (SchemaObject fields)) (Rec FieldRepr fields) Source #

textRepr :: (KnownSymbol fn, SingI fn, SingI cs) => Iso' (FieldRepr '(fn, SchemaText cs)) Text Source #

arrayRepr :: (KnownSymbol fn, SingI fn, SingI cs, SingI schema) => Iso' (FieldRepr '(fn, SchemaArray cs schema)) (Vector (JsonRepr schema)) Source #

objectRepr :: (KnownSymbol fn, SingI fn, SingI fields) => Iso' (FieldRepr '(fn, SchemaObject fields)) (Rec FieldRepr fields) Source #

optionalRepr :: (KnownSymbol fn, SingI fn, SingI schema) => Iso' (FieldRepr '(fn, SchemaOptional schema)) (Maybe (JsonRepr schema)) Source #