LayerModule

PackageAxial.Layers

Summary

NameSignatureSynopsis
fromAsyncLayer.fromAsync operationCreates a layer from a raw async provisioning function.
fromValueTaskLayer.fromValueTask operationCreates a layer from a raw value task provisioning function.
fromTaskLayer.fromTask operationCreates a layer from a raw task provisioning function.
succeedLayer.succeed valueCreates a layer that succeeds with a fixed output value.
envWithLayer.envWith projectionProjects part of the input environment into the layer output.
addFinalizerLayer.addFinalizer finalizerRegisters an asynchronous finalizer with the layer scope.
acquireReleaseLayer.acquireRelease acquire releaseAcquires a resource and registers its release with the layer scope.
mapLayer.map mapper layerMaps the successful output of a layer.
mapErrorLayer.mapError mapper layerMaps the typed provisioning failure of a layer.
bindLayer.bind binder layerSequences layer provisioning with a dependent follow-up layer.
zipLayer.zip left rightBuilds two layers from the same input and scope and returns both outputs.
zipParLayer.zipPar left rightBuilds two independent layers in parallel and returns both outputs.
mergeLayer.merge left rightMerges two independent service layers in parallel.
map2Layer.map2 mapper left rightCombines two layers with a mapping function.
applyLayer.apply layer valueApplies a layer-wrapped function to a layer-wrapped value.
map3Layer.map3 mapper left middle rightCombines three layers with a mapping function.
provideLayer.provide layer flowBuilds an environment with a layer, runs a downstream flow, and always closes the layer scope.

fromAsync

Layer.fromAsync operation
Member
Creates a layer from a raw async provisioning function.

Parameters

NameTypeDescription
operation'input * Scope -> CancellationToken -> Async<Exit<'output, 'error>>

Returns

Layer<'input, 'error, 'output>

fromValueTask

Layer.fromValueTask operation
Member
Creates a layer from a raw value task provisioning function.

Parameters

NameTypeDescription
operation'input * Scope -> CancellationToken -> ValueTask<Exit<'output, 'error>>

Returns

Layer<'input, 'error, 'output>

fromTask

Layer.fromTask operation
Member
Creates a layer from a raw task provisioning function.

Parameters

NameTypeDescription
operation'input * Scope -> CancellationToken -> Task<Exit<'output, 'error>>

Returns

Layer<'input, 'error, 'output>

succeed

Layer.succeed value
Member
Creates a layer that succeeds with a fixed output value.

Parameters

NameTypeDescription
value'output

Returns

Layer<'input, 'error, 'output>

envWith

Layer.envWith projection
Member
Projects part of the input environment into the layer output.

Parameters

NameTypeDescription
projection'input -> 'output

Returns

Layer<'input, 'error, 'output>

addFinalizer

Layer.addFinalizer finalizer
Member
Registers an asynchronous finalizer with the layer scope.

Parameters

NameTypeDescription
finalizerFinalizerThe finalizer to run when the layer scope closes.

Returns

Layer<'input, 'error, unit>

acquireRelease

Layer.acquireRelease acquire release
Member
Acquires a resource and registers its release with the layer scope.

Parameters

NameTypeDescription
acquireLayer<'input, 'error, 'resource>The layer that acquires the resource.
release'resource -> FinalizerThe release action to run when the layer scope closes.

Returns

Layer<'input, 'error, 'resource>

map

Layer.map mapper layer
Member
Maps the successful output of a layer.

Parameters

NameTypeDescription
mapper'output -> 'next
layerLayer<'input, 'error, 'output>

Returns

Layer<'input, 'error, 'next>

mapError

Layer.mapError mapper layer
Member
Maps the typed provisioning failure of a layer.

Parameters

NameTypeDescription
mapper'error -> 'nextError
layerLayer<'input, 'error, 'output>

Returns

Layer<'input, 'nextError, 'output>

bind

Layer.bind binder layer
Member
Sequences layer provisioning with a dependent follow-up layer.

Parameters

NameTypeDescription
binder'output -> Layer<'input, 'error, 'next>
layerLayer<'input, 'error, 'output>

Returns

Layer<'input, 'error, 'next>

zip

Layer.zip left right
Member
Builds two layers from the same input and scope and returns both outputs.

Parameters

NameTypeDescription
leftLayer<'input, 'error, 'left>
rightLayer<'input, 'error, 'right>

Returns

Layer<'input, 'error, ('left * 'right)>

zipPar

Layer.zipPar left right
Member
Builds two independent layers in parallel and returns both outputs.

Parameters

NameTypeDescription
leftLayer<'input, 'error, 'left>
rightLayer<'input, 'error, 'right>

Returns

Layer<'input, 'error, ('left * 'right)>

merge

Layer.merge left right
Member
Merges two independent service layers in parallel.

Parameters

NameTypeDescription
leftLayer<'input, 'error, 'left>
rightLayer<'input, 'error, 'right>

Returns

Layer<'input, 'error, ('left * 'right)>

map2

Layer.map2 mapper left right
Member
Combines two layers with a mapping function.

Parameters

NameTypeDescription
mapper'left -> 'right -> 'output
leftLayer<'input, 'error, 'left>
rightLayer<'input, 'error, 'right>

Returns

Layer<'input, 'error, 'output>

apply

Layer.apply layer value
Member
Applies a layer-wrapped function to a layer-wrapped value.

Parameters

NameTypeDescription
layerLayer<'input, 'error, ('value -> 'next)>
valueLayer<'input, 'error, 'value>

Returns

Layer<'input, 'error, 'next>

map3

Layer.map3 mapper left middle right
Member
Combines three layers with a mapping function.

Parameters

NameTypeDescription
mapper'left -> 'middle -> 'right -> 'output
leftLayer<'input, 'error, 'left>
middleLayer<'input, 'error, 'middle>
rightLayer<'input, 'error, 'right>

Returns

Layer<'input, 'error, 'output>

provide

Layer.provide layer flow
Member
Builds an environment with a layer, runs a downstream flow, and always closes the layer scope.

Parameters

NameTypeDescription
layerLayer<'input, 'error, 'environment>The layer that builds the downstream environment.
flowFlow<'environment, 'error, 'value>The flow to run with the provided environment.

Returns

Flow<'input, 'error, 'value>

Verification Examples

let program () =
    let runtimeLayer = Layer.succeed "production"
    let workflow = Flow.envWith String.length
    Layer.provide runtimeLayer workflow