schemas-0.2.0: schema guided serialization

Safe HaskellNone
LanguageHaskell2010

Schemas.Class

Synopsis

Documentation

class HasSchema a where Source #

Instances
HasSchema Bool Source # 
Instance details

Defined in Schemas.Class

HasSchema Double Source # 
Instance details

Defined in Schemas.Class

HasSchema Int Source # 
Instance details

Defined in Schemas.Class

HasSchema Integer Source # 
Instance details

Defined in Schemas.Class

HasSchema Natural Source # 
Instance details

Defined in Schemas.Class

HasSchema () Source # 
Instance details

Defined in Schemas.Class

Methods

schema :: TypedSchema () Source #

HasSchema Scientific Source # 
Instance details

Defined in Schemas.Class

HasSchema Text Source # 
Instance details

Defined in Schemas.Class

HasSchema Value Source # 
Instance details

Defined in Schemas.Class

HasSchema String Source # 
Instance details

Defined in Schemas.Class

HasSchema Field Source # 
Instance details

Defined in Schemas.Class

HasSchema Schema Source # 
Instance details

Defined in Schemas.Class

HasSchema OpenApi2Type Source # 
Instance details

Defined in Schemas.OpenApi2

HasSchema OpenApi2Schema Source # 
Instance details

Defined in Schemas.OpenApi2

HasSchema OpenApi2Document Source # 
Instance details

Defined in Schemas.OpenApi2

HasSchema a => HasSchema [a] Source # 
Instance details

Defined in Schemas.Class

Methods

schema :: TypedSchema [a] Source #

HasSchema a => HasSchema (Identity a) Source # 
Instance details

Defined in Schemas.Class

HasSchema a => HasSchema (NonEmpty a) Source # 
Instance details

Defined in Schemas.Class

(Eq a, Hashable a, HasSchema a) => HasSchema (HashSet a) Source # 
Instance details

Defined in Schemas.Class

HasSchema a => HasSchema (Vector a) Source # 
Instance details

Defined in Schemas.Class

(HasSchema a, HasSchema b) => HasSchema (Either a b) Source # 
Instance details

Defined in Schemas.Class

Methods

schema :: TypedSchema (Either a b) Source #

(HasSchema a, HasSchema b) => HasSchema (a, b) Source # 
Instance details

Defined in Schemas.Class

Methods

schema :: TypedSchema (a, b) Source #

(Eq key, Hashable key, HasSchema a, Key key) => HasSchema (HashMap key a) Source # 
Instance details

Defined in Schemas.Class

Methods

schema :: TypedSchema (HashMap key a) Source #

(HasSchema a, HasSchema b, HasSchema c) => HasSchema (a, b, c) Source # 
Instance details

Defined in Schemas.Class

Methods

schema :: TypedSchema (a, b, c) Source #

(HasSchema a, HasSchema b, HasSchema c, HasSchema d) => HasSchema (a, b, c, d) Source # 
Instance details

Defined in Schemas.Class

Methods

schema :: TypedSchema (a, b, c, d) Source #

(HasSchema a, HasSchema b, HasSchema c, HasSchema d, HasSchema e) => HasSchema (a, b, c, d, e) Source # 
Instance details

Defined in Schemas.Class

Methods

schema :: TypedSchema (a, b, c, d, e) Source #

class Key a where Source #

Methods

fromKey :: Text -> a Source #

toKey :: a -> Text Source #

Instances
Key Text Source # 
Instance details

Defined in Schemas.Class

Key String Source # 
Instance details

Defined in Schemas.Class

theSchema :: forall a. HasSchema a => Schema Source #

Extract the default Schema for a type

encode :: HasSchema a => a -> Value Source #

encode using the default schema

encodeTo :: HasSchema a => Schema -> Maybe (a -> Value) Source #

Attempt to encode to the target schema using the default schema. First encodes using the default schema, then computes a coercion applying isSubtypeOf, and then applies the coercion to the encoded data.

finiteEncode :: forall a. HasSchema a => Natural -> a -> Value Source #

Encode a value into a finite representation by enforcing a max depth

decode :: HasSchema a => Value -> Either [(Trace, DecodeError)] a Source #

Decode using the default schema.

decodeFrom :: HasSchema a => Schema -> Maybe (Value -> Either [(Trace, DecodeError)] a) Source #

Apply isSubtypeOf to construct a coercion from the source schema to the default schema, apply the coercion to the data, and attempt to decode using the default schema.

coerce :: forall sub sup. (HasSchema sub, HasSchema sup) => Value -> Maybe Value Source #

Coerce from sub to supReturns Nothing if sub is not a subtype of sup

field :: HasSchema a => Text -> (from -> a) -> RecordFields from a Source #

field name get introduces a field with the default schema for the type

optField :: forall a from. HasSchema a => Text -> (from -> Maybe a) -> RecordFields from (Maybe a) Source #

optField name get introduces an optional field with the default schema for the type

optFieldEither :: forall a from e. HasSchema a => Text -> (from -> Either e a) -> e -> RecordFields from (Either e a) Source #

optFieldEither name get introduces an optional field with the default schema for the type

alt :: HasSchema a => Text -> Prism' from a -> UnionTag from Source #

alt name prism introduces a discriminated union alternative with the default schema