schematic-0.4.2.0: JSON-biased spec and validation tool

Safe HaskellNone
LanguageHaskell2010

Data.Schematic.Schema

Synopsis

Documentation

type family CRepr (s :: Schema) :: Type where ... #

data TextConstraint #

Instances

Generic TextConstraint # 

Associated Types

type Rep TextConstraint :: * -> * #

SingKind TextConstraint # 
KnownNat n => SingI TextConstraint (TEq n) # 

Methods

sing :: Sing (TEq n) a #

KnownNat n => SingI TextConstraint (TLt n) # 

Methods

sing :: Sing (TLt n) a #

KnownNat n => SingI TextConstraint (TLe n) # 

Methods

sing :: Sing (TLe n) a #

KnownNat n => SingI TextConstraint (TGt n) # 

Methods

sing :: Sing (TGt n) a #

KnownNat n => SingI TextConstraint (TGe n) # 

Methods

sing :: Sing (TGe n) a #

(KnownSymbol s, SingI Symbol s) => SingI TextConstraint (TRegex s) # 

Methods

sing :: Sing (TRegex s) a #

SingI [Symbol] ss => SingI TextConstraint (TEnum ss) # 

Methods

sing :: Sing (TEnum ss) a #

Eq (Sing TextConstraint (TEq n)) # 
Eq (Sing TextConstraint (TLt n)) # 
Eq (Sing TextConstraint (TLe n)) # 
Eq (Sing TextConstraint (TGt n)) # 
Eq (Sing TextConstraint (TGe n)) # 
Eq (Sing TextConstraint (TRegex t)) # 
Eq (Sing TextConstraint (TEnum ss)) # 
type Rep TextConstraint # 
data Sing TextConstraint # 
type Demote TextConstraint # 

data DemotedTextConstraint #

data NumberConstraint #

Constructors

NLe Nat 
NLt Nat 
NGt Nat 
NGe Nat 
NEq Nat 

Instances

Generic NumberConstraint # 
SingKind NumberConstraint # 
KnownNat n => SingI NumberConstraint (NLe n) # 

Methods

sing :: Sing (NLe n) a #

KnownNat n => SingI NumberConstraint (NLt n) # 

Methods

sing :: Sing (NLt n) a #

KnownNat n => SingI NumberConstraint (NGt n) # 

Methods

sing :: Sing (NGt n) a #

KnownNat n => SingI NumberConstraint (NGe n) # 

Methods

sing :: Sing (NGe n) a #

KnownNat n => SingI NumberConstraint (NEq n) # 

Methods

sing :: Sing (NEq n) a #

Eq (Sing NumberConstraint (NLe n)) # 
Eq (Sing NumberConstraint (NLt n)) # 
Eq (Sing NumberConstraint (NGt n)) # 
Eq (Sing NumberConstraint (NGe n)) # 
Eq (Sing NumberConstraint (NEq n)) # 
type Rep NumberConstraint # 
data Sing NumberConstraint # 
type Demote NumberConstraint # 

data DemotedArrayConstraint #

Constructors

DAEq Integer 

Instances

data Schema #

Instances

Generic Schema # 

Associated Types

type Rep Schema :: * -> * #

Methods

from :: Schema -> Rep Schema x #

to :: Rep Schema x -> Schema #

SingKind Schema # 

Associated Types

type Demote Schema = (r :: *) #

SingI Schema SchemaBoolean # 

Methods

sing :: Sing SchemaBoolean a #

SingI Schema SchemaNull # 

Methods

sing :: Sing SchemaNull a #

SingI [TextConstraint] sl => SingI Schema (SchemaText sl) # 

Methods

sing :: Sing (SchemaText sl) a #

SingI [NumberConstraint] sl => SingI Schema (SchemaNumber sl) # 

Methods

sing :: Sing (SchemaNumber sl) a #

SingI [(Symbol, Schema)] stl => SingI Schema (SchemaObject stl) # 

Methods

sing :: Sing (SchemaObject stl) a #

SingI Schema s => SingI Schema (SchemaOptional s) # 

Methods

sing :: Sing (SchemaOptional s) a #

SingI [Schema] s => SingI Schema (SchemaUnion s) # 

Methods

sing :: Sing (SchemaUnion s) a #

(KnownSymbol name, SingI Schema schema, Serial m (JsonRepr schema)) => Serial m (FieldRepr ((,) Symbol Schema name schema)) # 

Methods

series :: Series m (FieldRepr ((Symbol, Schema) name schema)) #

(SingI [ArrayConstraint] ac, SingI Schema s) => SingI Schema (SchemaArray ac s) # 

Methods

sing :: Sing (SchemaArray ac s) a #

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

Associated Types

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

Methods

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

fget :: FGetter fn f (((Symbol, Schema) ': (Symbol, Schema) fn r) rs) Z #

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

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

Associated Types

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

Methods

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

fget :: FGetter r f (((Symbol, Schema) ': s) rs) (S i) #

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

Eq (JsonRepr schema) => Eq (FieldRepr ((,) Symbol Schema name schema)) # 

Methods

(==) :: FieldRepr ((Symbol, Schema) name schema) -> FieldRepr ((Symbol, Schema) name schema) -> Bool #

(/=) :: FieldRepr ((Symbol, Schema) name schema) -> FieldRepr ((Symbol, Schema) name schema) -> Bool #

Show (JsonRepr schema) => Show (FieldRepr ((,) Symbol Schema name schema)) # 

Methods

showsPrec :: Int -> FieldRepr ((Symbol, Schema) name schema) -> ShowS #

show :: FieldRepr ((Symbol, Schema) name schema) -> String #

showList :: [FieldRepr ((Symbol, Schema) name schema)] -> ShowS #

SingI [Schema] ((:) Schema h tl) => Representable (SchemaUnion ((:) Schema h tl)) # 

Methods

constructField :: Sing Symbol fn -> Proxy Schema (SchemaUnion ((Schema ': h) tl)) -> Repr (SchemaUnion ((Schema ': h) tl)) -> FieldRepr ((Symbol, Schema) fn (SchemaUnion ((Schema ': h) tl))) #

FSubset ([] (Symbol, Schema)) ss ([] Nat) # 

Methods

fsubset :: Functor g => (Rec (Symbol, Schema) f [(Symbol, Schema)] -> g (Rec (Symbol, Schema) f [(Symbol, Schema)])) -> Rec (Symbol, Schema) f ss -> g (Rec (Symbol, Schema) f ss) #

fcast :: Rec (Symbol, Schema) f ss -> Rec (Symbol, Schema) f [(Symbol, Schema)] #

freplace :: Rec (Symbol, Schema) f [(Symbol, Schema)] -> Rec (Symbol, Schema) f ss -> Rec (Symbol, Schema) f ss #

Eq (Sing Schema (SchemaText cs)) # 
Eq (Sing Schema SchemaBoolean) # 
Eq (Sing Schema (SchemaNumber cs)) # 
Eq (Sing Schema (SchemaObject cs)) # 
Eq (Sing Schema (SchemaArray as s)) # 

Methods

(==) :: Sing Schema (SchemaArray as s) -> Sing Schema (SchemaArray as s) -> Bool #

(/=) :: Sing Schema (SchemaArray as s) -> Sing Schema (SchemaArray as s) -> Bool #

Eq (Sing Schema SchemaNull) # 
Eq (Sing Schema (SchemaOptional s)) # 
Eq (Sing Schema (SchemaUnion s)) # 
ToJSON (Union Schema JsonRepr as) # 
(SingI Schema a, FromJSON (Union Schema JsonRepr as)) => FromJSON (Union Schema JsonRepr ((:) Schema a as)) # 
FromJSON (Union Schema JsonRepr ([] Schema)) # 
((~) Schema (ByField fn ss i) s, FElem fn ss i, FSubset rs ss is) => FSubset ((:) (Symbol, Schema) ((,) Symbol Schema fn s) rs) ss ((:) Nat i is) # 

Methods

fsubset :: Functor g => (Rec (Symbol, Schema) f (((Symbol, Schema) ': (Symbol, Schema) fn s) rs) -> g (Rec (Symbol, Schema) f (((Symbol, Schema) ': (Symbol, Schema) fn s) rs))) -> Rec (Symbol, Schema) f ss -> g (Rec (Symbol, Schema) f ss) #

fcast :: Rec (Symbol, Schema) f ss -> Rec (Symbol, Schema) f (((Symbol, Schema) ': (Symbol, Schema) fn s) rs) #

freplace :: Rec (Symbol, Schema) f (((Symbol, Schema) ': (Symbol, Schema) fn s) rs) -> Rec (Symbol, Schema) f ss -> Rec (Symbol, Schema) f ss #

type Rep Schema # 
data Sing Schema # 
type Demote Schema # 
type ByField fn ((:) (Symbol, Schema) ((,) Symbol Schema fn r) rs) Z # 
type ByField fn ((:) (Symbol, Schema) ((,) Symbol Schema fn r) rs) Z = r
type ByField r ((:) (Symbol, Schema) s rs) (S i) # 
type ByField r ((:) (Symbol, Schema) s rs) (S i) = ByField r rs i

data DemotedSchema #

Instances

Generic DemotedSchema # 

Associated Types

type Rep DemotedSchema :: * -> * #

type Rep DemotedSchema # 

data FieldRepr :: (Symbol, Schema) -> Type where #

Constructors

FieldRepr :: (SingI schema, KnownSymbol name) => JsonRepr schema -> FieldRepr '(name, schema) 

Instances

(KnownSymbol name, SingI Schema schema, Serial m (JsonRepr schema)) => Serial m (FieldRepr ((,) Symbol Schema name schema)) # 

Methods

series :: Series m (FieldRepr ((Symbol, Schema) name schema)) #

Eq (JsonRepr schema) => Eq (FieldRepr ((,) Symbol Schema name schema)) # 

Methods

(==) :: FieldRepr ((Symbol, Schema) name schema) -> FieldRepr ((Symbol, Schema) name schema) -> Bool #

(/=) :: FieldRepr ((Symbol, Schema) name schema) -> FieldRepr ((Symbol, Schema) name schema) -> Bool #

Show (JsonRepr schema) => Show (FieldRepr ((,) Symbol Schema name schema)) # 

Methods

showsPrec :: Int -> FieldRepr ((Symbol, Schema) name schema) -> ShowS #

show :: FieldRepr ((Symbol, Schema) name schema) -> String #

showList :: [FieldRepr ((Symbol, Schema) name schema)] -> ShowS #

toJsonRepr :: FieldRepr '(fn, sch) -> JsonRepr sch #

Forgetful Functor Ufr

knownFieldName :: forall proxy (fieldName :: Symbol) schema. KnownSymbol fieldName => proxy '(fieldName, schema) -> Text #

knownFieldSchema :: forall proxy fieldName schema. SingI schema => proxy '(fieldName, schema) -> Sing schema #

type family USubsets (u :: [k]) :: Constraint where ... #

Equations

USubsets '[] = () 
USubsets (h ': tl) = (USubset tl (h ': tl) (RImage tl (h ': tl)), USubsets tl) 

data JsonRepr :: Schema -> Type where #

Instances

(Monad m, Serial m (Rec (Symbol, Schema) FieldRepr fs)) => Serial m (JsonRepr (SchemaObject fs)) # 

Methods

series :: Series m (JsonRepr (SchemaObject fs)) #

Serial m (JsonRepr s) => Serial m (JsonRepr (SchemaOptional s)) # 
Serial m (Vector (JsonRepr s)) => Serial m (JsonRepr (SchemaArray cs s)) # 

Methods

series :: Series m (JsonRepr (SchemaArray cs s)) #

Monad m => Serial m (JsonRepr SchemaNull) # 
(Monad m, Serial m Scientific) => Serial m (JsonRepr (SchemaNumber cs)) # 

Methods

series :: Series m (JsonRepr (SchemaNumber cs)) #

(Monad m, Serial m Text) => Serial m (JsonRepr (SchemaText cs)) # 

Methods

series :: Series m (JsonRepr (SchemaText cs)) #

IsList (JsonRepr (SchemaArray cs s)) # 

Associated Types

type Item (JsonRepr (SchemaArray cs s)) :: * #

Eq (JsonRepr (SchemaText cs)) # 
Eq (JsonRepr (SchemaNumber cs)) # 
Eq (Rec (Symbol, Schema) FieldRepr fs) => Eq (JsonRepr (SchemaObject fs)) # 
Eq (JsonRepr s) => Eq (JsonRepr (SchemaArray as s)) # 

Methods

(==) :: JsonRepr (SchemaArray as s) -> JsonRepr (SchemaArray as s) -> Bool #

(/=) :: JsonRepr (SchemaArray as s) -> JsonRepr (SchemaArray as s) -> Bool #

Eq (JsonRepr SchemaNull) # 
Eq (JsonRepr s) => Eq (JsonRepr (SchemaOptional s)) # 
Num (JsonRepr (SchemaNumber cs)) # 
Show (JsonRepr (SchemaText cs)) #

Move to the union package

Show (JsonRepr (SchemaNumber cs)) # 
RecAll (Symbol, Schema) FieldRepr fs Show => Show (JsonRepr (SchemaObject fs)) # 
Show (JsonRepr s) => Show (JsonRepr (SchemaArray acs s)) # 

Methods

showsPrec :: Int -> JsonRepr (SchemaArray acs s) -> ShowS #

show :: JsonRepr (SchemaArray acs s) -> String #

showList :: [JsonRepr (SchemaArray acs s)] -> ShowS #

Show (JsonRepr SchemaNull) # 
Show (JsonRepr s) => Show (JsonRepr (SchemaOptional s)) # 
IsString (JsonRepr (SchemaText cs)) # 
ToJSON (JsonRepr a) # 
SingI Schema schema => FromJSON (JsonRepr schema) # 

Methods

parseJSON :: Value -> Parser (JsonRepr schema) #

parseJSONList :: Value -> Parser [JsonRepr schema] #

ToJSON (Union Schema JsonRepr as) # 
(SingI Schema a, FromJSON (Union Schema JsonRepr as)) => FromJSON (Union Schema JsonRepr ((:) Schema a as)) # 
FromJSON (Union Schema JsonRepr ([] Schema)) # 
type Item (JsonRepr (SchemaArray cs s)) # 
type Item (JsonRepr (SchemaArray cs s)) = JsonRepr s

parseUnion :: FromJSON (JsonRepr (SchemaUnion ss)) => sing (ss :: [Schema]) -> Value -> Parser (JsonRepr (SchemaUnion ss)) #

type family TopLevel (schema :: Schema) :: Constraint where ... #

Equations

TopLevel (SchemaArray acs s) = () 
TopLevel (SchemaObject o) = () 
TopLevel spec = True ~ False