-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Codec type for WebStorage, FetchStream, etc. #136
Comments
I think in cases like this, we should not fret too much about typeclasses :), especially now that they are first class citizens in Scala 3. A more substantial question I have is - why two type parameters? (I might be missing the idea here) |
Circe has all three (encoders, decoders, codecs) and they can be automatically derived both ways: |
Yes, encoders and decoders will be separate. Codec would just be a bundle of both that the user may choose to provide as a single instance, as is usual in json libs. WebStorageVar needs to encode/decode values between So... I'm not yet sure if FetchStream would be able to use json-style codecs that can only encode/decode into |
Currently,
FetchStream
andWebStorage
offerwithCodec(encodeFn, decodeFn)
builders.See if we can offer a
Codec[A, B]
typeclass that users could automatically derive from their existing JSON codecs (once per JSON lib, not once per type).Our APIs should require (Encoder[A, B], Decoder[A, B]) for maximum flexibility
Note that FetchStream needs some weird types, but we should be able to wrangle them into Encoder & Decoder
Consider all applications of these codecs across Airstream and Laminar – where do we want to use them? Do we have
decode
return aTry
, or throw instead? Shouldencode
ordecode
be allowed to throw?Ideally we should keep the current
withCodec
et al APIs because I think for many cases this would work just as well, without requiring the concept of typeclasses.The text was updated successfully, but these errors were encountered: