Typed, composable effects for F#. Provides Effect<R,E,A> with typed errors, dependency injection via environment, computation expressions, retry/repeat schedules, and cooperative cancellation.
Get Started
| Product | Versions |
|---|---|
| .NET |
README
Effect
Typed, composable effects for F#.
An Effect<'R, 'E, 'A> is a lazy description of a program that requires an environment 'R, can fail with a typed error 'E, and produces a value 'A.
Install
dotnet add package Effect --prerelease
Quick start
open Eff
type AppError = NotFound | Unauthorized
let program =
effect {
let! x = Effect.succeed 10
let! y = Effect.succeed 20
return x + y
}
let result = program |> Effect.run () |> fun t -> t.Result
// Ok 30
Error handling
let safe =
riskyOperation ()
|> Effect.catchAll (fun err ->
match err with
| NotFound -> Effect.succeed "default"
| other -> Effect.fail other)
Environment / dependency injection
type IAppEnv =
abstract Db: IDatabase
abstract Logger: ILogger
let getUser id : Effect<IAppEnv, AppError, User> =
effect {
let! env = Effect.env<IAppEnv, AppError>
let! user = env.Db.FindById id |> Effect.fromTaskResult
return user
}
let result = getUser 1 |> Effect.run myEnv
Retry with schedules
let resilient =
fetchFromApi ()
|> EffectSchedule.retry (
Schedule.exponentialN (TimeSpan.FromMilliseconds 100.0) 3)
Cooperative cancellation
CancellationToken flows through the entire effect chain.
let cts = new CancellationTokenSource()
cts.CancelAfter(1000)
let! result = Effect.runWithCancellation myEnv cts.Token myEffect
Related packages
- Effect.DI — composable dependency injection layers
- Effect.Concurrency — fibers, streams, concurrent data structures
- Effect.Platform — HTTP, file system, console with typed errors
Downloads by Version
Similar & Alternative Packages
Hand-picked matching NuGet libraries based on tags & ecosystem
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.