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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object AppLoop {
* @param terminateWhen loop termination check
*/

def statefulLoop[State, Settings, Subsystem <: LowLevelSubsystem[Settings], F[-_, +_]](
def statefulLoop[State, Settings, Subsystem <: LowLevelSubsystem[Settings], F[-_, _]](
renderFrame: State => F[Subsystem, State],
terminateWhen: State => Boolean = (_: State) => false
)(implicit effect: FrameEffect[F]): AppLoop.Definition[State, Settings, Subsystem] = {
Expand Down Expand Up @@ -107,7 +107,7 @@ object AppLoop {
* @param renderFrame operation to render the frame
* @param frameRate frame rate limit
*/
def statelessLoop[Settings, Subsystem <: LowLevelSubsystem[Settings], F[-_, +_]](
def statelessLoop[Settings, Subsystem <: LowLevelSubsystem[Settings], F[-_, _]](
renderFrame: F[Subsystem, Unit]
)(implicit effect: FrameEffect[F]): AppLoop.Definition[Unit, Settings, Subsystem] =
statefulLoop[Unit, Settings, Subsystem, F]((_) => renderFrame)
Expand All @@ -118,7 +118,7 @@ object AppLoop {
* @param renderFrame operation to render the frame and update the state
* @param terminateWhen loop termination check
*/
def statefulRenderLoop[State, F[-_, +_]](
def statefulRenderLoop[State, F[-_, _]](
renderFrame: State => F[Canvas, State],
terminateWhen: State => Boolean = (_: State) => false
)(implicit effect: FrameEffect[F]): AppLoop.Definition[State, Canvas.Settings, LowLevelCanvas] =
Expand All @@ -131,7 +131,7 @@ object AppLoop {
*
* @param renderFrame operation to render the frame
*/
def statelessRenderLoop[F[-_, +_]](
def statelessRenderLoop[F[-_, _]](
renderFrame: F[Canvas, Unit]
)(implicit effect: FrameEffect[F]): AppLoop.Definition[Unit, Canvas.Settings, LowLevelCanvas] =
statelessLoop[Canvas.Settings, LowLevelCanvas, F](
Expand All @@ -144,7 +144,7 @@ object AppLoop {
* @param renderFrame operation to render the frame and update the state
* @param terminateWhen loop termination check
*/
def statefulAudioLoop[State, F[-_, +_]](
def statefulAudioLoop[State, F[-_, _]](
renderFrame: State => F[AudioPlayer, State],
terminateWhen: State => Boolean = (_: State) => false
)(implicit effect: FrameEffect[F]): AppLoop.Definition[State, AudioPlayer.Settings, LowLevelAudioPlayer] =
Expand All @@ -157,7 +157,7 @@ object AppLoop {
*
* @param renderFrame operation to render the frame
*/
def statelessAudioLoop[F[-_, +_]](
def statelessAudioLoop[F[-_, _]](
renderFrame: F[AudioPlayer, Unit]
)(implicit
effect: FrameEffect[F]
Expand All @@ -175,7 +175,7 @@ object AppLoop {
* @param renderFrame operation to render the frame and update the state
* @param terminateWhen loop termination check
*/
def statefulAppLoop[State, F[-_, +_]](
def statefulAppLoop[State, F[-_, _]](
renderFrame: State => F[Canvas with AudioPlayer, State],
terminateWhen: State => Boolean = (_: State) => false
)(implicit
Expand All @@ -200,7 +200,7 @@ object AppLoop {
*
* @param renderFrame operation to render the frame
*/
def statelessAppLoop[F[-_, +_]](
def statelessAppLoop[F[-_, _]](
renderFrame: F[Canvas with AudioPlayer, Unit]
)(implicit
effect: FrameEffect[F]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package eu.joaocosta.minart.runtime

/** Typeclass for effect types for computations that run on each frame.
*
* `F1[Subsystem, NewState]` represents a computation that takes a subsystem and returns a new state.
* `F2[Subsystem, OldState, NewState]` represents a computation that takes a subsystem and an old state returns a
* new state.
* `F[Subsystem, NewState]` represents a computation that takes a subsystem and returns a new state.
*/
trait FrameEffect[F[-_, +_]] {
trait FrameEffect[F[-_, _]] {
def contramap[A, AA, B](f: F[A, B], g: AA => A): F[AA, B]
def unsafeRun[A, B](f: F[A, B], subsystem: A): B
}
Expand Down