Repository F# setup
open System
open System.IO
open System.Threading
open System.Threading.Tasks
open Axial
open Axial.Console
open Axial.FileSystem
open Axial.Hosting
open Axial.Hosting.Browser
open Axial.Hosting.Node
open Axial.State
open Axial.Telemetry
open Axial.Telemetry.JavaScriptRandom.* and Guid.newGuid read runtime services, not fields in 'env. Use Flow.withRandom and
Flow.withGuid to override them for a subtree, including forked fibers. Leaving that subtree restores the outer
services. IRandom and IGuid are defined in Axial; their modules keep the Axial namespace
but ship in the Axial package.
Randomness
| 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 fresh array |
Pin each value kind independently in a test:
> open Axial;;
> open Axial;;
> let fixedRandom () = Random.fromFixed 7 0.25 9uy;;
> (Random.nextInt 1 10 : Flow<unit, Never, int>) |> Flow.withRandom (fixedRandom ()) |> Flow.run ();;
> (Random.nextDouble : Flow<unit, Never, float>) |> Flow.withRandom (fixedRandom ()) |> Flow.run ();;
> (Random.bytes 3 : Flow<unit, Never, byte array>) |> Flow.withRandom (fixedRandom ()) |> Flow.run ();;val it: Exit<int,Never> = Success 7
val it: Exit<float,Never> = Success 0.25
val it: Exit<Byte[],Never> = Success [|9uy; 9uy; 9uy|]AxialfixedRandom: unit -> IRandomAxial.RandomHelpers for the random-number service.
fromFixed: int -> float -> byte -> IRandomCreates a deterministic random generator from fixed integer, double, and byte values.
nextInt: int -> int -> Flow<'env,'error,int>Reads a random integer from an explicit random-number service.
Axial.Flow`3unitThe type 'unit', which has only one value "()". This value is special and always uses the representation 'null'. Basic Types
Axial.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.FlowwithRandom: IRandom -> Flow<'env,'error,'value> -> Flow<'env,'error,'value>Overrides random values within this flow and its descendants.
run: '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.live is the runtime default. Random.seeded seed creates a repeatable generator; construct it once per
test rather than sharing mutable generator state across tests. Random.fromValue integer pins integer reads;
Random.fromFixed integer double byte pins all three kinds. Scripted implementations can deliberately return
values outside normal generator bounds, so choose values appropriate to the operation under test.
None of these generators are cryptographic. For secrets, tokens and nonces, use System.Security.Cryptography
inside an explicit capability, not the runtime's ordinary random service.
GUIDs
> open System;;
> open Axial;;
> open Axial;;
> let tagged name : Flow<unit, Never, string> = Guid.newGuid |> Flow.map (fun id -> $"{name}-{id}");;
> tagged "order" |> Flow.withGuid (Guid.fromValue (System.Guid.Parse "11111111-1111-1111-1111-111111111111")) |> Flow.run ();;val it: Exit<string,Never> = Success "order-11111111-1111-1111-1111-111111111111"SystemAxialtagged: 'a -> Flow<unit,Never,string>name: 'aAxial.Flow`3unitThe type 'unit', which has only one value "()". This value is special and always uses the representation 'null'. Basic Types
Axial.NeverRepresents an error channel that cannot occur.
stringAn abbreviation for the CLI type . Basic Types
Axial.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: GuidwithGuid: IGuid -> Flow<'env,'error,'value> -> Flow<'env,'error,'value>Overrides GUID generation within this flow and its descendants.
fromValue: Guid -> IGuidCreates a deterministic GUID service that always returns the supplied value.
Parse: string -> GuidConverts the string representation of a GUID to the equivalent structure. The string to convert. A structure that contains the value that was parsed. is . is not in a recognized format.
System.GuidRepresents a globally unique identifier (GUID).
run: '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
Guid.live is the default. Guid.fromValue returns the same identifier on every call. Guid.sequence supplies
a finite scripted sequence and fails clearly on exhaustion. Use a fresh generator per test.
Flow.runTest creates seeded randomness and an infinite sequential GUID generator for each run, alongside its
manual clock and recording log. For custom sequences, set TestPlatform.Random / Guid before
Flow.runTestWith platform env, or use the scoped overrides above. A library function can use these readers under
any application environment without adding platform-service interfaces to its signature.

