Chisle
코딩 에이전트 플러그인, 20개 실시간 작업에서 기본 모델 52% 활용, 간결한 페르소나와 출력 압축 제공
메이커가 쓴 소개는 위의 한 줄이 전부입니다. 더 자세한 내용은 저장소 README에서 읽을 수 있습니다. 저장소 README ↗
README 전체를 불러오는 중입니다.
README 전문 보기 ↗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.
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.
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.
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.