schemas-0.3.0: schema guided serialization

Safe HaskellNone
LanguageHaskell2010

Schemas.Untyped

Synopsis

Documentation

newtype SchemaName Source #

Constructors

SchemaName String 
Instances
Eq SchemaName Source # 
Instance details

Defined in Schemas.Untyped

Show SchemaName Source # 
Instance details

Defined in Schemas.Untyped

IsString SchemaName Source # 
Instance details

Defined in Schemas.Untyped

HasSchema SchemaName Source # 
Instance details

Defined in Schemas.Class

data Schema Source #

A schema for untyped data, such as JSON or XML.

Constructors

Array Schema 
StringMap Schema 
Enum (NonEmpty Text) 
Record (HashMap Text Field) 
OneOf (NonEmpty Schema)

Decoding works for all alternatives, encoding only for one

Prim Text

Carries the name of primitive type

Named SchemaName Schema 
Instances
Eq Schema Source # 
Instance details

Defined in Schemas.Untyped

Methods

(==) :: Schema -> Schema -> Bool #

(/=) :: Schema -> Schema -> Bool #

Show Schema Source # 
Instance details

Defined in Schemas.Untyped

Generic Schema Source # 
Instance details

Defined in Schemas.Untyped

Associated Types

type Rep Schema :: Type -> Type #

Methods

from :: Schema -> Rep Schema x #

to :: Rep Schema x -> Schema #

Semigroup Schema Source # 
Instance details

Defined in Schemas.Untyped

Monoid Schema Source # 
Instance details

Defined in Schemas.Untyped

HasSchema Schema Source # 
Instance details

Defined in Schemas.Class

type Rep Schema Source # 
Instance details

Defined in Schemas.Untyped

data Field Source #

Constructors

Field 

Fields

Instances
Eq Field Source # 
Instance details

Defined in Schemas.Untyped

Methods

(==) :: Field -> Field -> Bool #

(/=) :: Field -> Field -> Bool #

Show Field Source # 
Instance details

Defined in Schemas.Untyped

Methods

showsPrec :: Int -> Field -> ShowS #

show :: Field -> String #

showList :: [Field] -> ShowS #

Generic Field Source # 
Instance details

Defined in Schemas.Untyped

Associated Types

type Rep Field :: Type -> Type #

Methods

from :: Field -> Rep Field x #

to :: Rep Field x -> Field #

HasSchema Field Source # 
Instance details

Defined in Schemas.Class

type Rep Field Source # 
Instance details

Defined in Schemas.Untyped

type Rep Field = D1 (MetaData "Field" "Schemas.Untyped" "schemas-0.3.0-JAYuDPycTib4oO1qL86IJR" False) (C1 (MetaCons "Field" PrefixI True) (S1 (MetaSel (Just "fieldSchema") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Schema) :*: S1 (MetaSel (Just "isRequired") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))

pattern Empty :: Schema Source #

type Trace = [Text] Source #

validate :: Validators -> Schema -> Value -> [(Trace, Mismatch)] Source #

Structural validation of a JSON value against a schema Ignores extraneous fields in records

isSubtypeOf :: Validators -> Schema -> Schema -> Either [(Trace, Mismatch)] (Value -> Value) Source #

sub isSubtypeOf sup returns a witness that sub is a subtype of sup, i.e. a cast function sub -> sup

Array Bool `isSubtypeOf` Bool

Just function > Record [("a", Bool)] isSubtypeOf Record [("a", Number)] Nothing

type Path = Int Source #

selectPath :: Path -> [a] -> Maybe a Source #

lookup :: (Eq a, Foldable f) => a -> f (a, b) -> Maybe b Source #

Generalized lookup for Foldables