Repository F# setup
open System
open System.IO
open System.Threading
open System.Threading.Tasks
open Axial
open Axial.Layers
open Axial.Console
open Axial.FileSystem
open Axial.Hosting
open Axial.Hosting.Browser
open Axial.Hosting.Node
open Axial.HttpClient
open Axial.PlatformService
open Axial.Process
open Axial.State
open Axial.Telemetry
open Axial.Telemetry.JavaScriptIClock has one member, UtcNow(), and always reports UTC. Reading it through the service is what lets a test
choose the instant:
open System
open Axial
open Axial.PlatformService
SystemAxialPlatformServicelet expiresWithin (window: TimeSpan) (expiry: DateTimeOffset) : Flow<#IHasClock, Never, bool> =
Clock.now |> Flow.map (fun now -> expiry - now <= window)
expiresWithin: TimeSpan -> DateTimeOffset -> Flow<'a,Never,bool>window: TimeSpanSystem.TimeSpanRepresents a time interval.
expiry: DateTimeOffsetSystem.DateTimeOffsetRepresents a point in time, typically expressed as a date and time of day, relative to Coordinated Universal Time (UTC).
Axial.Flow`3Represents a cold workflow that reads an environment, returns a typed result, and is executed explicitly through one of its execution members such as ToTask, ToAsync, or RunSynchronously. The type of the environment dependency. The type of the failure value. The type of the success value.
Axial.PlatformService.IHasClockDeclares that an environment supplies the clock service.
Axial.NeverRepresents an error channel that cannot occur.
boolAn abbreviation for the CLI type . Basic Types
Axial.PlatformService.ClockHelpers for the clock service.
now: Flow<'env,'error,DateTimeOffset>Reads the current UTC timestamp from an explicit clock service.
(|>): 'T1 -> ('T1 -> 'U) -> 'UApply a function to a value, the value being on the left, the function on the right The argument. The function. The function result. let doubleIt x = x * 2 3 |> doubleIt // Evaluates to 6
Axial.Flowmap: ('value -> 'next) -> Flow<'env,'error,'value> -> Flow<'env,'error,'next>Transforms the successful value of a flow. If the source fails, the is not executed. The original failure cause is preserved, including typed failures, interruption, and defects. Use map for pure value transformations after an effect has succeeded. A function of type 'value -> 'next to transform the successful value. The source flow of type to transform. A new with the transformed success value of type 'next. let flow = Flow.succeed 1 |> Flow.map (fun x -> x + 1)
now: DateTimeOffset(-): ^T1 -> ^T2 -> ^T3Overloaded subtraction operator The first parameter. The second parameter. The result of the operation. 10 - 2 // Evaluates to 8
(<=): 'T -> 'T -> boolStructural less-than-or-equal comparison The first parameter. The second parameter. The result of the comparison. 5 <= 1 // Evaluates to false 5 <= 5 // Evaluates to true [1; 5] <= [1; 6] // Evaluates to true
Clock.now // DateTimeOffset
Clock.utcDateTime // DateTime, Kind = Utc
Clock.unixTimeSeconds // int64
Clock.unixTimeMilliseconds // int64
Axial.PlatformService.ClockHelpers for the clock service.
now: Flow<'env,'error,DateTimeOffset>Reads the current UTC timestamp from an explicit clock service.
utcDateTime: Flow<'env,'error,DateTime>Reads the current UTC date/time from an explicit clock service.
unixTimeSeconds: Flow<'env,'error,int64>Reads the current Unix timestamp in seconds from an explicit clock service.
unixTimeMilliseconds: Flow<'env,'error,int64>Reads the current Unix timestamp in milliseconds from an explicit clock service.
Supplying the service
Clock.live reads DateTimeOffset.UtcNow. Clock.layer is the same value as a Layer<unit, Never, IClock>. Most
applications get the clock as part of the base runtime rather than wiring it alone.
Testing
Clock.fromValue pins the instant, which turns a time-dependent assertion into an ordinary one:
let clock = Clock.fromValue (DateTimeOffset.Parse "2026-01-01T12:00:00Z")
let exit = expiresWithin (TimeSpan.FromHours 1.0) deadline |> Flow.run { Clock = clock }Note that IClock reports the time; it does not schedule. Delays, timeouts, and retry policies are Flow runtime
concerns — see scheduling and retries.

