Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The Transform
typeclass with various types and helper functions
for evaluating transformations.
Synopsis
- class Transform a where
- transform :: MonadError TransformErrorBundle m => TransformFn a -> TransformCtx a -> a -> m a
- validate :: TemplatingEngine -> TransformFn a -> Validation TransformErrorBundle ()
- throwErrorBundle :: MonadError TransformErrorBundle m => Text -> Maybe Value -> m a
- wrapUnescapedTemplate :: UnescapedTemplate -> Template
- encodeScalar :: MonadError TransformErrorBundle m => Value -> m ByteString
Documentation
class Transform a where Source #
Transform
describes how to reify a defunctionalized transformation for
a particular request field.
transform :: MonadError TransformErrorBundle m => TransformFn a -> TransformCtx a -> a -> m a Source #
transform
is a function which takes TransformFn
of a
and reifies
it into a function of the form:
ReqTransformCtx -> a -> m a
validate :: TemplatingEngine -> TransformFn a -> Validation TransformErrorBundle () Source #
Validate a TransformFn
of a
.
Instances
throwErrorBundle :: MonadError TransformErrorBundle m => Text -> Maybe Value -> m a Source #
A helper function for serializing transformation errors to JSON.
wrapUnescapedTemplate :: UnescapedTemplate -> Template Source #
Wrap an UnescapedTemplate
with escaped double quotes.
encodeScalar :: MonadError TransformErrorBundle m => Value -> m ByteString Source #
Encode a JSON Scalar Value as a ByteString
.
If a non-Scalar value is provided, will return a TrnasformErrorBundle