Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove covariance from FrameEffect #311

Merged
merged 1 commit into from
Feb 11, 2023
Merged

Conversation

JD557
Copy link
Owner

@JD557 JD557 commented Feb 11, 2023

Removes the covariance requirement from FrameEffect.

This didn't make much sense anyway, as that parameter would be either ignored (on a stateless loop) or be be used as an input for the loop (on a stateless loop).

This also allows for some very primitive cats-effect interop with

// Not really needed, but it helps to be able to use all minart-pure helpers
implicit def asSyncIO[S, A](rio: RIO[S, A]): Kleisli[SyncIO, S, A] = Kleisli.ask[SyncIO, S].map(s => rio.run(s))

implicit val catsFrameEffect: FrameEffect[[S, A] =>> Kleisli[SyncIO, S, A]] = new FrameEffect {
  def contramap[A, AA, B](f: Kleisli[SyncIO, A, B], g: AA => A): Kleisli[SyncIO, AA, B] = f.local(g)
  def unsafeRun[A, B](f: Kleisli[SyncIO, A, B], subsystem: A): B = f.run(subsystem).unsafeRunSync()
}

Which, while not great (I'm still not sure how I can support async IO yet), it's already a nice step forward towards #18 .

@JD557 JD557 added this to the 0.5.0 milestone Feb 11, 2023
@JD557 JD557 merged commit 32611c0 into experimental-0.5 Feb 11, 2023
@JD557 JD557 deleted the improve-interop branch February 11, 2023 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant