Hi, i´m playing a little with the context receiver...
# arrow
c
Hi, i´m playing a little with the context receivers, and i have a question/problem:
EitherEffect<Error,*> it´s not able to match with the any concrete type (like Int, Any?, String, etc)
message has been deleted
Having
EitherEffect<Error,A>
instead of
EitherEffect<Error,*>
would be a right solution?
r
Hi @carbaj0, once this is merged and we do the next release you would not need that additional type argument. https://github.com/arrow-kt/arrow/pull/2661
c
🙌 , I love how Kotlin and Arrow are evolving.
s
Nice blog ! Tried that myself in one of my production application, just to see how it will look. Its awesome. But limitation that we cant pass multiple parameters in with makes the start of program nasty. Also, because context receiver is available on function level, it brings repetition to all the functions using it, which basically is another way of writing a function passing the dependencies as a parameters. It would have been nice if context receiver is available on interfaces, then we could have very nice bounded contexts. Tried setting context receiver on interface, it compiles but it doesn’t run 😄
s
But limitation that we cant pass multiple parameters in with makes the start of program nasty.
This is planned afaik, but it's not been implemented in the current preview.
it brings repetition to all the functions using it
There is some repetition, yes, but I don't see this as a bad thing perse. You only need to add the receivers the function actually uses, so it's similar to effect handlers or final tagless in Haskell/Scala.
👍 2
t
Hi @simon.vergauwen I tried following your blog and guide on how to install the experimental version of kotlin to check out content recievers however i do not know how (and cannot find a solution) to getting past this ide issue
r
hi @Tower Guidev2, I believe you have to add the compiler option in gradle freeCompilerArgs for
-Xcontext-receivers
and also the same in the IDE Kotlin settings, for some reason in my case the IDE its not picking the setting from Gradle.
t
thanks, i have added that and i can now build cleanly however the red error is still shown on ide, its very odd... i think i will "give up" and wait for this feature to become available in the stable release 😄
s
@Tower Guidev2 did you update the Kotlin plugin to the EAP version? You need to have 1.6.20-EAP Kotlin plugin in IDEA, but it only works in IDEA
2021.3.2
.
t
Hi I have this version of IDEA
IntelliJ IDEA 2021.3.2 (Community Edition)
Build #IC-213.6777.52, built on January 28, 2022
and Kotlin plugin version...
s
Oh, that's very strange. That setup is working for me. Then it's probably a Gradle cache issue where it isn't picking up the
-Xcontext-receivers
flag. Can you try the repo I linked in my blogpost, that is working for me with the setup you're using. https://github.com/nomisRev/context-receivers-blog