Skip to content

Conversation

@VOSID8
Copy link
Contributor

@VOSID8 VOSID8 commented Apr 21, 2024

I'm working keeping in mind the other Java2D algebras as reference utilizing reified data structure and package. I'm facing bit of a trouble with expressing relationships between types with ReifiedClip and Reified.

  val ClipApi = new ClipApi {
    def clip[A](
        tx: Tx,
        img: Drawing[A],
        clipPath: ClosedPath
    ): Reification[A] = {
      WriterT.tell(List(Reified.clip(tx, img, clipPath)))
    }
  }
[error] -- [E007] Type Mismatch Error: C:\Projects\doodle\java2d\src\main\scala\doodle\java2d\algebra\reified\ReifiedClip.scala:44:6 
[error] 44 |      WriterT.tell(List(Reified.clip(tx,img, clipPath)))
[error]    |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |      Found:    cats.data.WriterT[[A] =>> doodle.java2d.Drawing[A],
[error]    |        List[doodle.java2d.algebra.reified.Reified], Unit]
[error]    |      Required: doodle.java2d.algebra.reified.Reification[A┬▓]
[error]    |
[error]    |      where:    A  is a type variable with constraint
[error]    |                A┬▓ is a type in method clip

@VOSID8 VOSID8 changed the title Clipping4 Implementing Clipping with Reified Apr 21, 2024
@noelwelsh
Copy link
Contributor

The source of the error you are seeing comes from the type parameter C you added to the Clip reified instruction (and you also added a type parameter to render). This approach won't work with Reified: it is intended to be a simple list of instructions (a "linear IR") without any nesting. The way you have represented Clip has nesting, which introduces the type parameter that is causing you problems. You need to get rid of the nesting, and then things will work.

I've added some additional documentation to Reified that explains how the instructions should be represented (a linear IR) and describes how you can solve the problem you'll encounter when you try to implement clipping in this representation.

@noelwelsh noelwelsh force-pushed the main branch 2 times, most recently from 2ece10b to b1f4488 Compare December 13, 2024 17:16
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.

2 participants