GitHub

Transformation

API reference for Transformation.

decode turns an E into a T, encode back, needing the services RD / RE (Effect's Transformation).

Attributes

AttributeTypeDescription
decodeGetter[T, E, RD_co]
encodeGetter[E, T, RE_co]
contentContent | None = None

What encode writes, when it writes a document of a media type (JSON text): JSON Schema says it with contentMediaType.

decode_contentContent | None = None

content of decode, carried for flip.

sees_failuresbool

Functions

__init__

__init__(decode, encode, content=None, decode_content=None) -> None
ParameterTypeDescription
decodeGetter[T, E, RD_co]
encodeGetter[E, T, RE_co]
contentContent | None = None
decode_contentContent | None = None

flip

flip() -> Transformation[E, T, RE_co, RD_co]

The transformation the other way.

Returns Transformation[E, T, RE_co, RD_co]

def flip(self) -> Transformation[E, T, RE_co, RD_co]:
    """The transformation the other way."""
    return Transformation(self.encode, self.decode, self.decode_content, self.content)

pipe

pipe[B](f) -> B
ParameterTypeDescription
fCallable[[Self], B]

Returns B

def pipe[B](self, f: Callable[[Self], B], /) -> B:
    return f(self)

compose

compose[T2, RD2 = Never, RE2 = Never](other) -> Transformation[T2, E, RD_co | RD2, RE_co | RE2]

This transformation, then other (Effect's composeTransformation).

ParameterTypeDescription
otherTransformation[T2, T, RD2, RE2]

Returns Transformation[T2, E, RD_co | RD2, RE_co | RE2]

def compose[T2, RD2 = Never, RE2 = Never](
    self, other: Transformation[T2, T, RD2, RE2], /
) -> Transformation[T2, E, RD_co | RD2, RE_co | RE2]:
    """This transformation, then ``other`` (Effect's
    ``composeTransformation``)."""
    return Transformation(self.decode.compose(other.decode), other.encode.compose(self.encode))

decode_result

decode_result(result, options) -> ParseResult
ParameterTypeDescription
resultParseResult
optionsParseOptions

Returns ParseResult

def decode_result(self, result: ParseResult, options: ParseOptions) -> ParseResult:
    return apply_result(self.decode, result, options)