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.PlatformService
open Axial.State
open Axial.Telemetry
open Axial.Telemetry.JavaScriptDeclare IRandom and IGuid as dependencies to control generated values in tests. A direct call to Guid.NewGuid() cannot be pinned to a chosen value.
open System
open Axial
open Axial.PlatformService
SystemAxialPlatformServiceRandomness
| Function | Result |
|---|---|
Random.next |
A non-negative int |
Random.nextMax exclusiveMax |
0 <= value < exclusiveMax |
Random.nextInt minimum maximum |
minimum <= value < maximum |
Random.nextDouble |
0.0 <= value < 1.0 |
Random.nextBytes buffer |
Fills an existing buffer |
Random.bytes count |
Allocates and fills a new array |
With the base runtime's generator replaced by a fixed one, every call is predictable:
> open Axial.PlatformService;;
> let runtime () = { BaseRuntime.liveValue with Random = Random.fromFixed 7 0.25 9uy };;
> (Random.nextInt 1 10 : Flow<BaseRuntime, Never, int>) |> Flow.run (runtime ());;
> (Random.nextDouble : Flow<BaseRuntime, Never, float>) |> Flow.run (runtime ());;
> (Random.bytes 3 : Flow<BaseRuntime, Never, byte array>) |> Flow.run (runtime ());;val it: Exit<int,Never> = Success 7
val it: Exit<float,Never> = Success 0.25
val it: Exit<Byte[],Never> = Success [|9uy; 9uy; 9uy|]AxialPlatformServiceruntime: unit -> BaseRuntimeAxial.PlatformService.BaseRuntimeGroups the standard operational services commonly used by workflow hosts.
Axial.PlatformService.BaseRuntimeModuleHelpers for constructing the standard explicit service bundle used by workflow hosts.
liveValue: BaseRuntimeCreates the standard live base runtime as an explicit service bundle.
Random: IRandomAxial.PlatformService.RandomHelpers for the random-number service.
nextInt: int -> int -> Flow<'env,'error,int>Reads a random integer from an explicit random-number service.
Axial.Flow`3Axial.NeverRepresents an error channel that cannot occur.
intAn abbreviation for the CLI type . Basic Types
(|>): '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.Flowrun: 'env -> Flow<'env,'error,'value> -> Exit<'value,'error>Runs the workflow and blocks until the final exit is available. The environment used by the workflow. The workflow to run. The final workflow exit. let exit = workflow |> Flow.run environment
nextDouble: Flow<'env,'error,float>Reads a random floating-point value from an explicit random-number service.
floatAn abbreviation for the CLI type . Basic Types
bytes: int -> Flow<'env,'error,byte array>Creates a byte array filled through an explicit random-number service.
byteAn abbreviation for the CLI type . Basic Types
arraySingle dimensional, zero-based arrays, written int array, string array etc. Use the values in the module to manipulate values of this type, or the notation arr.[x] to get/set array values. Basic Types
Random.bytes allocates, fills, and returns a fresh array.
Random.live is backed by the platform generator. Two doubles cover most tests: Random.fromValue returns the same
integer from every method, and Random.fromFixed integer double byte pins the three value kinds separately when a
test cares about the difference.
None of these are cryptographic. For key material or tokens, use a cryptographic generator behind your own service
contract rather than IRandom.
GUIDs
IGuid has one member. Guid.newGuid reads it:
let tagged name : Flow<#IHasGuid, Never, string> =
Guid.newGuid |> Flow.map (fun id -> $"{name}-{id}")
tagged: 'a -> Flow<'b,Never,string>name: 'aAxial.Flow`3Axial.PlatformService.IHasGuidDeclares that an environment supplies the GUID service.
Axial.NeverRepresents an error channel that cannot occur.
stringAn abbreviation for the CLI type . Basic Types
Axial.PlatformService.GuidHelpers for the GUID service.
newGuid: Flow<'env,'error,Guid>Reads a GUID from an explicit GUID 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)
id: GuidGuid.live calls System.Guid.NewGuid(). Guid.fromValue returns a fixed identifier, which makes generated
identifiers assertable:
> open System;;
> open Axial.PlatformService;;
> let runtime () = { BaseRuntime.liveValue with Guid = Guid.fromValue (Guid.Parse "11111111-1111-1111-1111-111111111111") };;
> let tagged name : Flow<BaseRuntime, Never, string> = Guid.newGuid |> Flow.map (fun id -> $"{name}-{id}");;
> tagged "order" |> Flow.run (runtime ());;val it: Exit<string,Never> = Success "order-11111111-1111-1111-1111-111111111111"SystemAxialPlatformServiceruntime: unit -> BaseRuntimeAxial.PlatformService.BaseRuntimeGroups the standard operational services commonly used by workflow hosts.
Axial.PlatformService.BaseRuntimeModuleHelpers for constructing the standard explicit service bundle used by workflow hosts.
liveValue: BaseRuntimeCreates the standard live base runtime as an explicit service bundle.
Guid: IGuidtagged: 'a -> Flow<BaseRuntime,Never,string>name: 'aAxial.Flow`3Axial.NeverRepresents an error channel that cannot occur.
stringAn abbreviation for the CLI type . Basic Types
Axial.PlatformService.GuidHelpers for the GUID service.
newGuid: Flow<'env,'error,Guid>Reads a GUID from an explicit GUID 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)
id: Guidrun: 'env -> Flow<'env,'error,'value> -> Exit<'value,'error>Runs the workflow and blocks until the final exit is available. The environment used by the workflow. The workflow to run. The final workflow exit. let exit = workflow |> Flow.run environment
A fixed IGuid returns the same value every call. When a test needs distinct-but-predictable identifiers,
implement IGuid over a counter, so the sequence is defined in the test, not in the workflow.
Both services are part of the base runtime, so applications usually receive them as one bundle rather than wiring each.

