Skip to content
adzPublic

About

Ergonomic asynchronous F# workflows whose expected failures and required dependencies are visible in their types.

Topics

Resources

Stars

7 stars

Watchers

2 watching

Forks

Latest commit

 

History

1,382 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Axial

Axial

Write asynchronous F# workflows whose expected failures and required dependencies are visible in their types.

ci docs NuGet License

Warning

Axial is pre-1.0 and its API may change before the first stable release.

Your first flow

A handler usually needs services and can fail, but a Task signature shows neither fact. Flow<'env, 'error, 'value> makes both part of the contract.

open Axial

type CheckoutError =
    | OrderNotFound of orderId: int
    | PaymentDeclined of reason: string

type Receipt = { OrderId: int; Total: decimal; Reference: string }

type CheckoutEnv =
    { FindTotal: int -> ColdTask<Result<decimal, CheckoutError>>
      Charge: decimal -> ColdTask<Result<string, CheckoutError>> }

let checkout orderId : Flow<CheckoutEnv, CheckoutError, Receipt> =
    flow {
        let! findTotal = Flow.envWith _.FindTotal
        let! charge = Flow.envWith _.Charge
        let! total = findTotal orderId
        let! reference = charge total
        return { OrderId = orderId; Total = total; Reference = reference }
    }

The application supplies live functions. A test supplies a record of fakes. The workflow does not change.

Adding a timeout and a retry policy leaves the Flow<CheckoutEnv, CheckoutError, Receipt> signature unchanged. The runtime supplies its clock and owns cancellation, retries, and cleanup:

open System

let checkoutOrder orderId : Flow<CheckoutEnv, CheckoutError, Receipt> =
    checkout orderId
    |> Flow.retry (Schedule.recurs 2)
    |> Flow.timeout (TimeSpan.FromSeconds 5.0) (PaymentDeclined "checkout timed out")

Flow also carries concurrency, scheduling, streams, and structured child fibers through the same runtime. Clock, random and GUID values are scoped runtime services; application authority stays in 'env. Use Flow.withClock, Flow.withRandom and Flow.withGuid to override values for a flow and its descendants. Log.info writes to the current ILogSink (Information+ on stderr by default); install or decorate destinations with Flow.withLogSink / Flow.mapLogSink, and observation callbacks with Flow.withTelemetry.

Core Axial ships these runtime services under the Axial namespace. Flow.runTest env creates a fresh epoch manual clock, seeded random, sequential GUIDs and a recording log. Timed tests explicitly advance TestClock after observing sleeper registration; time never advances automatically. See runtime services.

Install

dotnet add package Axial

Package family

See the package maturity table for each package's rating and application evidence. The package catalogue links the first-class libraries and the complete compatibility matrix.

Documentation and examples

Reified integration

Reified declares value, model, JSON, and HTTP contracts. Axial's optional server adapters execute Reified HTTP contracts as workflows; neither core depends on the other. Axial 0.12 requires Reified 0.12.1 or later, whose Fable schema builder supports typed schema construction and Config.load decoding on Fable.

About

Ergonomic asynchronous F# workflows whose expected failures and required dependencies are visible in their types.

Topics

Resources

Stars

7 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages