BindModule

PackageAxial
Creates error-adaptation markers for let!, do!, and return! in flow { }.

Summary

NameSignatureSynopsis
errorerror failure sourceAssigns an error to a missing or unit-error source at a flow { } bind site.
mapErrormapError mapper sourceMaps an existing source error at a flow { } bind site.

error

error failure source
Member
Assigns an error to a missing or unit-error source at a flow { } bind site.

Parameters

NameTypeDescription
failure'errorThe error to use if the source fails.
source^sourceThe source to adapt.

Returns

BindError<'env, 'error, 'value>

Verification Examples

flow {
    let! user = maybeUser |> Bind.error InvalidUser
    do! Result.requireTrue () isValid |> Bind.error InvalidInput
}

mapError

mapError mapper source
Member
Maps an existing source error at a flow { } bind site.

Parameters

NameTypeDescription
mapper'error1 -> 'error2The error mapping function.
source^sourceThe source to adapt.

Returns

BindError<'env, 'error2, 'value>

Verification Examples

flow {
    do! authorize user |> Bind.mapError Unauthorized
}