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

Writer conveniences #149

Open
noelwelsh opened this issue Mar 13, 2024 · 0 comments
Open

Writer conveniences #149

noelwelsh opened this issue Mar 13, 2024 · 0 comments

Comments

@noelwelsh
Copy link
Contributor

noelwelsh commented Mar 13, 2024

There are two conveniences that will be useful on writers:

  • methods using a DefaultFrame (depends on Abstract default frame #148) instead of requiring the user to pass a Frame
  • methods that return just the output type and discard the A value in the Picture (A is almost always Unit; discarding it is what draw does.)

These can both be implemented as syntax. (It's good to not have redundant methods on the type classes / algebras, though this is not consistently followed.)

(What's below is more speculative.)

There are a number of writers that don't require any input beyond the Picture and Frame (e.g. writing to an value, like Base64 or a BufferedImage). To ensure consistency for these kinds of writers we can define a subtype of Writer, let's say ValueWriter:

trait ValueWriter[..., Out] extends Writer [...] {
  def write(picture: ..., frame: ...): IO[(A, Out)]
}

Then we can define syntax on ValueWriter that all implementations will automatically have. Probably something like

picture.to[Out]

where the type variable Out is used to select the ValueWriter instance.

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

No branches or pull requests

1 participant