doodle
doodle copied to clipboard
Writer conveniences
There are two conveniences that will be useful on writers:
- methods using a
DefaultFrame
(depends on #148) instead of requiring the user to pass aFrame
- methods that return just the output type and discard the
A
value in thePicture
(A
is almost alwaysUnit
; discarding it is whatdraw
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.