Is there any notion of introducing some kind of al...
# arrow-meta
t
Is there any notion of introducing some kind of algebraic effect system with arrow meta like with Frank, Unison, or some of the Haskell libraries like Freer-Simple? I’d be very interested in something like that 👀
r
Hi @tavish pegram, This will actually be possible with multiple context receivers which is currently in the kotlin roadmap and it even has a working prototype in a compiler branch. Once that lands
Capabilities
or algebraic effects are nothing more than
interface
or
fun interface
or any other declaration for that matter that can be declared as one of the context receivers and usually involves suspend funs. https://youtrack.jetbrains.com/issue/KT-10468 @Alejandro Serrano Mena @simon.vergauwen and I had discussed this week some features to complement this multiple receivers and a way to do polymorphism similar to how expect / actual work today in the sense that it has no abstraction runtime cost. Using the arrow-continuation library as foundation and including some of the Effect abstractions we already have for reset / shift in the continuation model we may develop more similar effects that you would be able to use in the same way languages like Unison declare Capabilities. Currently in Kotlin the missing piece in the context receiver proposal is a means to provide implicit materialization of a
with
function that makes all those context concrete, the current solution forces you to nest multiple
with
or
run
calls over each context before you can invoke a contextual function. With Arrow meta we can reduce that boilerplate nesting for you and potentially resolving implicitly contextual instances you declare as providers. All algebraic effects are representable in the current continuation model Kotlin has for suspend fun except for multi-shot effects or in general any deterministic effects like List or Streams which instead of DSLs like monad bind they provide push like DSLs
yield
or
emit
As for categorising those patterns and making a library for Algebraic effects it’s still unexplored. Discussing with Simon and Alejandro effects shown in papers like ambient, flips and others are toy utils. People need FileSystem, Cache and other more powerful abstractions that help with real use case in applications. TLDR; yes, once context receivers land we can have a pattern for
Capabilities
just using interfaces, suspend and multiple context receivers. If you want to collaborate in this regards feel free to open an issue and list which Capabilities you’d like to have and we can discuss them here or on github and see what comes out of it. 🙂
🎉 1
t
Very cool! I will submit an issue later today!
s
That feature will make it 100% better though
t
After some delay i’ve created the issue! https://github.com/arrow-kt/arrow/issues/2556 🙌
r
thank you @tavish pegram!