GitHub

Transform

API reference for Transform.

f of a present value; none stays none.

Attributes

AttributeTypeDescription
fCallable[[E_contra], T_co]
tag= 'Transform'

Functions

__init__

__init__(f) -> None
ParameterTypeDescription
fCallable[[E_contra], T_co]

apply

apply(value, options) -> ParseResult
ParameterTypeDescription
valueobject
optionsParseOptions

Returns ParseResult

def apply(self, value: object, options: ParseOptions) -> ParseResult:
    if value is MISSING:
        return MISSING_EXIT
    return _present(self.f, value)

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, R2 = Never](other) -> Getter[T2, E_contra, R_co | R2]

This getter, then other on its output (Effect's compose).

ParameterTypeDescription
otherGetter[T2, T_co, R2]

Returns Getter[T2, E_contra, R_co | R2]

def compose[T2, R2 = Never](
    self, other: Getter[T2, T_co, R2], /
) -> Getter[T2, E_contra, R_co | R2]:
    """This getter, then ``other`` on its output (Effect's ``compose``)."""
    return cast("Getter[T2, E_contra, R_co | R2]", _compose(self, other))

map

map[T2](f) -> Getter[T2, E_contra, R_co]

The output changed by f.

ParameterTypeDescription
fCallable[[T_co], T2]

Returns Getter[T2, E_contra, R_co]

def map[T2](self, f: Callable[[T_co], T2], /) -> Getter[T2, E_contra, R_co]:
    """The output changed by ``f``."""
    return self.compose(Transform(f))