PolicyModule

PackageAxial
Constructors and combinators for environment-aware workflow requirements.

Summary

NameSignatureSynopsis
liftlift operation mapError environment inputLifts a pure result-returning function and maps its error into the workflow error type.
withErrorwithError operation errorLifts a pure result-returning function and replaces any error with a fixed workflow error.
contextcontext operation mapError environment inputLifts an environment-aware result-returning function and maps its error into the workflow error type.
passpass environment inputA policy that returns the input unchanged.
composecompose first second environment inputComposes two policies left to right.
optionaloptional enabled policy environment inputRuns a policy only when the environment predicate is true; otherwise returns the input unchanged.

lift

lift operation mapError environment input
Member
Lifts a pure result-returning function and maps its error into the workflow error type.

Parameters

NameTypeDescription
operation'input -> Result<'output, 'innerError>
mapError'innerError -> 'error
environment'env
input'input

Returns

Result<'output, 'error>

withError

withError operation error
Member
Lifts a pure result-returning function and replaces any error with a fixed workflow error.

Parameters

NameTypeDescription
operation'input -> Result<'output, 'innerError>
error'error

Returns

Policy<'env, 'error, 'input, 'output>

context

context operation mapError environment input
Member
Lifts an environment-aware result-returning function and maps its error into the workflow error type.

Parameters

NameTypeDescription
operation'env -> 'input -> Result<'output, 'innerError>
mapError'innerError -> 'error
environment'env
input'input

Returns

Result<'output, 'error>

pass

pass environment input
Member
A policy that returns the input unchanged.

Parameters

NameTypeDescription
environment'env
input'input

Returns

Result<'input, 'error>

compose

compose first second environment input
Member
Composes two policies left to right.

Parameters

NameTypeDescription
firstPolicy<'env, 'error, 'input, 'middle>
secondPolicy<'env, 'error, 'middle, 'output>
environment'env
input'input

Returns

Result<'output, 'error>

optional

optional enabled policy environment input
Member
Runs a policy only when the environment predicate is true; otherwise returns the input unchanged.

Parameters

NameTypeDescription
enabled'env -> bool
policyPolicy<'env, 'error, 'input, 'input>
environment'env
input'input

Returns

Result<'input, 'error>