Using CpsMonadConversion with async/await without Direct-syntax? #106
Replies: 3 comments 1 reply
-
Sorry, I can't understand the problem from the description. Perhaps a concrete example can help clarify the point. CpsMonadConversion does not require DirectSyntax. We use conversion in projects that are compiled without a plugin. Maybe the problem is a message during implicit search: when CpsMonadConversion is not found, the compiler reports that the implicit value is not found and tells that CpsDirect was looking as a candidate(?). But it's hard to see something without an example. |
Beta Was this translation helpful? Give feedback.
-
Yes exactly, I was guided by the compiler error.
However the missing implicit in my case is not the Conversion, as I've
defined that locally myself.
It's the CpsMonadContext implicit. I assumed from the error msg that it was
related to, or depends on, Direct syntax. Also noticed there is a field in
the Context trait that mentions Direct as well.
…On Mon, 28 July 2025, 6:30 am Ruslan Shevchenko, ***@***.***> wrote:
Sorry, I can't understand the problem from the description. Perhaps a
concrete example can help clarify the point.
CpsMonadConversion does not require DirectSyntax. We use conversion in
projects that are compiled without a plugin.
Maybe the problem is a message during implicit search: when
CpsMonadConversion is not found, the compiler reports that the implicit
value is not found and tells that CpsDirect was looking as a candidate(?).
But it's hard to see something without an example.
—
Reply to this email directly, view it on GitHub
<#106 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAXJZDLTNG64SOLOC4MF6D3KUZFDAVCNFSM6AAAAACCPGLHAKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGOJQGM2TQNA>
.
You are receiving this because you authored the thread.Message ID:
<dotty-cps-async/dotty-cps-async/repo-discussions/106/comments/13903584@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
OK, resolved and working :) There were two issues. Some of the compiler error messages led me in the wrong direction. Combined with my inexperience with Dotty CPS I drew wrong conclusion about what the true problem was (that's common with Dotty CPS for me I find). Here's the code in question:
Which led away from the true cause.
Initially my given instant for listing Either[Throwable, *] had signature Once I added the PS Finally, you'll notice I use non-direct syntax for the Resource block ie |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Ruslan,
I noticed
[CpsMonadConversion][F[_], G[_]]
, which apparently permitsawait
on aF[A]
within aasync[G]
block.However, my attempts to get it to compile have been unsuccessful.
The use case I have is Cats Effect. We usually have
IO
(probably expressed asF[_]: Async
) as our overall effect type, but it's common for my subexpressions to have type[A] =>> Either[Throwable, A]
or[A] =>> Either[String, A]
(ie pure computation may fail, but dosnt do IO effects).Sometimes I'd like to "auto-homogenize" these weaker effects by lifting them to IO. We can do with
liftTo[F].await
but writing that repeatedly gets boring. I was hoping to teach the system how toawait
on them and auto-lift.The problem I see seems to related to Direct syntax. I don't and can't use Direct-syntax, because the compiler plugin requirement is impossible in my context. But somehow using
CpsMonadConversion
wants to pull in Direct syntax typeclass, viaCpsMonadContext
.Can they be separated out, so that people using basic explicit async/await can also enjoy benefits of CpsMonadConversion?
Beta Was this translation helpful? Give feedback.
All reactions