PolicyType

Constructors and combinators for environment-aware workflow requirements.

Specification

Kind
Type
Members
6
Examples
0
liftSignature
lift operation mapError environment input
withErrorSignature
withError operation error
contextSignature
context operation mapError environment input
passSignature
pass environment input
composeSignature
compose first second environment input

Summary

NameSignatureSynopsis
Operations
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.

Operations

kind:member

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>
kind:member

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>
kind:member

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>
kind:member

pass

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

Parameters

NameTypeDescription
environment'env
input'input

Returns

Result<'input, 'error>
kind:member

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>
kind:member

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>