https://github.com/gabryon99/kotlin-effects
A Kotlin library implementing algebraic effect handlers.
https://github.com/gabryon99/kotlin-effects
algebraic-effect-handlers algebraic-effects continuations kotlin thesis
Last synced: 10 months ago
JSON representation
A Kotlin library implementing algebraic effect handlers.
- Host: GitHub
- URL: https://github.com/gabryon99/kotlin-effects
- Owner: gabryon99
- License: mit
- Created: 2023-10-01T16:14:32.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-23T15:17:49.000Z (over 2 years ago)
- Last Synced: 2024-11-07T14:32:20.048Z (over 1 year ago)
- Topics: algebraic-effect-handlers, algebraic-effects, continuations, kotlin, thesis
- Language: Kotlin
- Homepage:
- Size: 574 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kotlin Effects
A Kotlin library implementing **algebraic effect handlers**. This library
is the result of my thesis did at the **Technical University of Munich** with the collaboration of **JetBrains Research**.
The library shows the feasibility of implementing algebraic effect handlers within
the Kotlin programming language. Here is a brief list containing library's main points:
* Effects are defined with classes/objects inhereting from the `Effect` interface.
* Effectful computations are invoked within a `handle e with h` expression, where `e` is an effectful function and `h` is an effect handler.
* The library **does not support** multishot continuations.
* The provided handler semantics is the **deep** one.
* Effects are performed using the `do/perform` notation (maybe not the best Kotlin idiomatic choice).
```kotlin
object Read: Effect
@Test
fun `MPretnar - Simple Read Effect`() {
handle {
val firstName = perform(Read)
val lastname = perform(Read)
println("Full Name: $firstName $lastname")
} with { effect ->
when (effect) {
is Read -> resume("Bob")
else -> unhandled()
}
}
}
```
Effect handlers are implemented on top of Kotlin's coroutines system, using linear continuations.