Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class HasSchema a where
- schema :: TypedSchema a
- class Key a where
- theSchema :: forall a. HasSchema a => Schema
- validatorsFor :: forall a. HasSchema a => Validators
- encode :: HasSchema a => a -> Value
- encodeTo :: HasSchema a => Schema -> Maybe (a -> Value)
- finiteEncode :: forall a. HasSchema a => Natural -> a -> Value
- decode :: HasSchema a => Value -> Either [(Trace, DecodeError)] a
- decodeFrom :: HasSchema a => Schema -> Maybe (Value -> Either [(Trace, DecodeError)] a)
- coerce :: forall sub sup. (HasSchema sub, HasSchema sup) => Value -> Maybe Value
- field :: HasSchema a => Text -> (from -> a) -> RecordFields from a
- optField :: forall a from. HasSchema a => Text -> (from -> Maybe a) -> RecordFields from (Maybe a)
- optFieldEither :: forall a from e. HasSchema a => Text -> (from -> Either e a) -> e -> RecordFields from (Either e a)
- alt :: HasSchema a => Text -> Prism' from a -> UnionTag from
Documentation
class HasSchema a where Source #
schema :: TypedSchema a Source #
Instances
validatorsFor :: forall a. HasSchema a => Validators Source #
finiteEncode :: forall a. HasSchema a => Natural -> a -> Value Source #
Encode a value into a finite representation by enforcing a max depth
decodeFrom :: HasSchema a => Schema -> Maybe (Value -> Either [(Trace, DecodeError)] a) Source #
coerce :: forall sub sup. (HasSchema sub, HasSchema sup) => Value -> Maybe Value Source #
Coerce from sub
to sup
Returns Nothing
if sub
is not a subtype of sup
optField :: forall a from. HasSchema a => Text -> (from -> Maybe a) -> RecordFields from (Maybe a) Source #
optFieldEither :: forall a from e. HasSchema a => Text -> (from -> Either e a) -> e -> RecordFields from (Either e a) Source #