Orsak.AspNetCore.OpenApi 0.9.0

dotnet add package Orsak.AspNetCore.OpenApi --version 0.9.0
                    
NuGet\Install-Package Orsak.AspNetCore.OpenApi -Version 0.9.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Orsak.AspNetCore.OpenApi" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Orsak.AspNetCore.OpenApi" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="Orsak.AspNetCore.OpenApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Orsak.AspNetCore.OpenApi --version 0.9.0
                    
#r "nuget: Orsak.AspNetCore.OpenApi, 0.9.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Orsak.AspNetCore.OpenApi@0.9.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Orsak.AspNetCore.OpenApi&version=0.9.0
                    
Install as a Cake Addin
#tool nuget:?package=Orsak.AspNetCore.OpenApi&version=0.9.0
                    
Install as a Cake Tool

Orsak


eff {
    let! line = Console.readLine ()
    do! Console.writeLine $"Hello {line}"
}

Orsak is a library for functional effects in F#, allowing pragmatic and composable modelling of side-effects through interfaces. It is inspired by Zio, with F# encoding similar to the approach described by Bartosz Sypytkowski here. The library intends to be as complete as is practical, including a computation expression, supporting functions and operators, and should be compatible with FSharpPlus.

However, Orsak is not intended to be a framework. Rather, it is encouraged and recommended to make use of the existing .NET ecosystem, and Orsak is intended to make that as easy and friction-free as possible. It can be used piecemeal, and introduced to existing codebases in isolated chunks.


This implementation makes use of resumable code to implement the computation expression builder for the lowest possible overhead. The builder also has various overloads for Bind, allowing for friction free interop with TaskLike<'a>, Async<'a>, Result<'T,'E> and more. It supports for, while, use, try-with and try-finally, and also applicative bind when the error-type supports +. While the computation expression is the intended way of working with effects, the corresponding module should contain all the expected functions.

NuGet Badge Build & Tests

Show me the code


Imagine having the following interfaces, which each describes some none-pure operation, that is, they both have side-effects.

type IButtonPusher =
    abstract member PushButton: unit -> Task<unit>
    
type IBeanCounter =
    abstract member CountBeans: unit -> Task<int>

By creating the following helper-interfaces

type IButtonPusherProvider =
    abstract member ButtonPusher: IButtonPusher
    
type IBeanCounterProvider =
    abstract member BeanCounter: IBeanCounter

and the following helpers

let pushButton () =
    Effect.Create(fun (provider: #IButtonPusherProvider) -> provider.ButtonPusher.PushButton())
    
let countBeans () =
    Effect.Create(fun (provider: #IBeanCounterProvider) -> provider.BeanCounter.CountBeans())

then it is possible to partially apply, or 'inject' these interfaces into your code by simply making functions calls:

let pushAndCount<'a, 'b when 'a :> IButtonPusherProvider and 'a :> IBeanCounterProvider> ()
    : Effect<'a, int, 'b> =
    eff {
        do! pushButton ()
        let! beans = countBeans ()
        return beans * 2
    }

In essence, this is a partially applied function, waiting for an instance of 'a which implements both IButtonPusherProvider and IBeanCounterProvider. Now, in practise you do not need to specify any of this, the type inference will keep track of the requirements of your provider.

let pushAndCount () =
    eff {
        do! pushButton()
        let! beans = countBeans()
        return beans * 2
    }

And adding further calls to functions with side-effects will apply the correct constraints seamlessly.

Generating the boilerplate

The provider interfaces and Effect.Create helpers above can be generated at build time by Orsak.Myriad, a Myriad plugin:

[<GenEffects>]
type IButtonPusher =
    abstract member PushButton: unit -> Task<unit>

See Generating code for setting it up, and the showcase sample for a complete example.

Documentation

The documentation is at https://johsand.github.io/Orsak/, with guides to errors, resilience, effect sequences, web APIs, OpenAPI, testing and generating code, and the API reference.

To build, test, or work on the documentation, see CONTRIBUTING.md.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.0 40 11/17/2026
0.8.0 131 11/8/2026

### Changed
**Breaking:** the `Effect` type's static `Return` returns an effect of the type it's a member of, `Effect<'r, 'a, 'e>.Return: 'a -> Effect<'r, 'a, 'e>`, instead of being a generic method returning any effect, so code compiled against 0.8.0 that calls it must be recompiled. A second `Return` takes an effect of the type and returns a function making one, and a static `Bind` binds an effect, as `>>=` does

### Added
Fable support for JavaScript: `Effect`, `eff` and the `Effect` module, from the `Orsak` package, which carries the sources Fable compiles. Effects run on `Task`, which Fable compiles to promises, and `fanOut`, effect sequences, the base effects, resilience and scopes are .NET only, see the Fable guide (experimental)
Orsak.Remoting and Orsak.Remoting.AspNetCore: a client, compiled with Fable or on .NET, calls the members of an interface on an ASP.NET Core server, which serves them with `MapRemote`. The wire format is pluggable, `IWireFormat`, and JSON is the first, the same on .NET and Fable; the contract's errors cross as values, and a failed call raises `RemoteCallException`, see the Remoting guide (experimental)
Orsak.Myriad: `[<GenRemote>]` generates the proxy of a remote interface, which makes the codecs of each member once, so a type the format can't write fails when the proxy is made, as `MapRemote` does when it maps the endpoints (experimental)
Orsak.Remoting: a format of a self-describing encoding is `WireFormat(encoding)`, Orsak.Remoting's mapping of F# types to `WireValue`s with an `IWireEncoding` of them to bytes, a few dozen lines over a library such as MessagePack-CSharp or System.Text.Json; `Conformance` checks an encoding, and that a client's and a server's encodings agree. `JsonFormat` is the JSON encoding's, with the content type `application/vnd.orsak+json`, writes byte arrays as base64, and reads non-public types (experimental)
Orsak.Remoting: `RemoteCallException.StatusCode` is the status the server answered, such as 401 or 403, or `None` if it couldn't be reached; `FetchTransport` takes headers, asked for on each request, such as a bearer token, and fetch's credentials mode. Orsak.Remoting.AspNetCore: a member's attributes, such as `[<Authorize(Roles = "editor")>]`, are its endpoint's metadata, and arguments that can't be read are answered 400, not 500. The Remoting guide has a section on authorization (experimental)
Orsak.Remoting: enums, by name, the smaller integer types, `uint32` and `uint64`, maps, sets, `ResizeArray`, `HashSet`, `Dictionary`, `float32`, `DateTime`, `DateTimeOffset`, `DateOnly`, `TimeOnly` and `TimeSpan` cross the wire, the dates and times as ISO 8601 strings written the same on .NET and Fable, and an option of an option keeps `Some None` apart from `None` (experimental)
Orsak.Remoting: a member taking a `CancellationToken` can be cancelled. The token isn't sent: the client's aborts the request, so the call raises `OperationCanceledException`, and `MapRemote` passes the member the request's `RequestAborted` in its place. A member returning `Async` is cancelled with the `Async`. A transport's `Post` takes the token too (experimental)
Orsak.Remoting: a member returning a `RemoteStream` streams its items, which the client reads as they come, on Fable and .NET. On .NET it is an `IAsyncEnumerable`, so a server returns one, such as an effect sequence; on Fable, an interface with members of the same names. Each reading is a call, pulled item by item, and stopping it ends the call. A transport has `PostStream`, and `[<GenRemote>]` generates the proxies of stream members, see the Remoting guide (experimental)
Fable: the base effects `Time`, `GuidGenerator`, `Random` and `CancellationSource`. Fable has no `System.TimeProvider`, so an `ITimeProvider`'s clock is Orsak's own `TimeProvider` there, with `TimeProvider.System` and `GetUtcNow` as on .NET; `Time.delay` isn't ended by the environment's cancellation source on Fable. Code generated by `[<GenEffects>]` compiles with Fable, see the Fable guide (experimental)

### Fixed
`return!` of a `Task<'T>` in an `eff` returns the task's value, instead of `unit`, and can be used in a `try` block too
The `Effect` type's `<*>` applies an effect of a function to an effect of its argument, for FSharpPlus too, as up to 0.5.0. From 0.6.0 it expected the function to return the type it was applied to, so it couldn't be used
A `for` in an `effList` runs its body in a loop when the effect runs, so it can go over any number of items. It nested an effect for each item, which overflowed the stack at a few hundred, copied the list so far for each, and ran each body as the effect was built, so an error didn't stop the loop
An `effSeq` disposed before its end, as by a reader that stops early or is cancelled, runs its `finally` blocks and disposes what it `use`s, innermost first. They didn't run, so what the sequence had opened stayed open