colomboe / KIO

A simple, lightweight IO monad implementation for Kotlin with effect rotation
https://colomboe.github.io/KIO/
Apache License 2.0
60 stars 4 forks source link

Error from the example. #5

Closed wpoosanguansit closed 4 years ago

wpoosanguansit commented 4 years ago

Hi,

I am checking out the code sample and it is throwing compile error:

Unresolved reference: unsafeRunSync

from line val userInput = option.unsafeRunSync().getOrNull()

Thanks.

colomboe commented 4 years ago

Thank you very much for reporting this issue! I've already fixed the example code that was based on a very early KIO release. I've moved the unsafeRunSync function inside the Runtime class (see the updated example).

I've introduced this change because now you can choose between Runtime and RuntimeSuspended. The second one is more capable and it is the only one that can manage async code, but it introduces the dependency on coroutines and also starts a new coroutine on the unsafeRunSync call. If your code doesn't need specific performance optimisations, I suggest to always use RuntimeSuspended.

Please let me know if this solves your issue or if you have any other problem related to this.

wpoosanguansit commented 4 years ago

Thank you for sharing your code. I am checking out to see if I can use your code to structure Kotlin code that is using Springboot. First piece is the DI and I am seeing the example in https://github.com/colomboe/KIO/blob/master/kio/src/test/kotlin/it/msec/kio/integration/ModularEnvironmentTest.kt https://github.com/colomboe/KIO/blob/master/kio/src/test/kotlin/it/msec/kio/integration/ModularEnvironmentTest.kt. So I am going to try that out. Another question that I have is do you plan to intern with Arrow like ZIO interops with Cats? That way users can just bring in effects from Arrow I think. Thanks again for your help.

On Mar 1, 2020, at 1:37 AM, Emanuele Colombo notifications@github.com wrote:

Thank you very much for reporting this issue! I've already fixed the example code that was based on a very early KIO release. I've moved the unsafeRunSync function inside the Runtime class (see the updated example).

I've introduced this change because now you can choose between Runtime and RuntimeSuspended. The second one is more capable and it is the only one that can manage async code, but it introduces the dependency on coroutines and also starts a new coroutine on the unsafeRunSync call. If your code doesn't need specific performance optimisations, I suggest to always use RuntimeSuspended.

Please let me know if this solves your issue or if you have any other problem related to this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/colomboe/KIO/issues/5?email_source=notifications&email_token=AAAWE3LOEU6CAYLHATH3TKDRFIUFBA5CNFSM4K7BKEN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENMZ5FY#issuecomment-593075863, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAWE3OMKMCVEWTKBJIQGFDRFIUFBANCNFSM4K7BKENQ.

colomboe commented 4 years ago

I use it with Spring Boot, so I'm sure there are good ways to make KIO work together with Spring Boot. I could publish something about this if you think it could be useful.

About the integration with Arrow, right now I don't have plans to work on this since Arrow and KIO are following two very different philosophies: lightweight and minimal for KIO, big and full-featured for Arrow.

But I don't know, maybe in the future, for sure after the Arrow 1.0 release.

wpoosanguansit commented 4 years ago

No not at all. I am getting rid of Spring Boot. I just found a project that implement some features in Kotlin using it. I am familiar with ZIO so I looked around in Kotlin and found your work. So I would love to structure my code using your KIO and getting rid of Spring Boot all together and just use the util code from the other project. I appreciate your reply and help.

On Mar 1, 2020, at 10:12 AM, Emanuele Colombo notifications@github.com wrote:

I use it with Spring Boot, so I'm sure there are good ways to make KIO work together with Spring Boot. I could publish something about this if you think it could be useful.

About the integration with Arrow, right now I don't have plans to work on this since Arrow and KIO are following two very different philosophies: lightweight and minimal for KIO, big and full-featured for Arrow.

But I don't know, maybe in the future, for sure after the Arrow 1.0 release.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/colomboe/KIO/issues/5?email_source=notifications&email_token=AAAWE3MOY3A5BNPX6BKFARDRFKQPRA5CNFSM4K7BKEN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENNGLYQ#issuecomment-593126882, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAWE3OPXI5BVWBFKE52OTLRFKQPRANCNFSM4K7BKENQ.

wpoosanguansit commented 4 years ago

On the interop with Arrow, I am not sure how relevant it is at this point. I guess the question could be would you be making KIO an instance of Arrow's Monad or MonadError or the equivalent of Concurrent structures like the ones found in ZIO with Cats - https://github.com/zio/interop-cats. Users of KIO can easily bring in typeclasses from Arrow easier without them running the effects prematurely is what I like to go for.