Skip to content

Instantly share code, notes, and snippets.

@nomisRev
Created September 21, 2021 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomisRev/2e4f06bcffd01833df612114814eefa0 to your computer and use it in GitHub Desktop.
Save nomisRev/2e4f06bcffd01833df612114814eefa0 to your computer and use it in GitHub Desktop.
Arrow Computation block `eager` vs `suspend`
The DSL uses the suspension system, but the Restricted version uses @RestrictSuspension.
This disallows any suspend function to be called inside the DSL except for the functions defined inside RestrictOptionEffect.
This means that the DSL can be evaluated immediately, or eagerly. Instead of requiring suspend.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-restricts-suspension/
If you’re already inside a suspend context then it makes most sense to just use the suspend version. That’ll also allow you to use other suspending code inside the DSL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment