-
Notifications
You must be signed in to change notification settings - Fork 109
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
Define our own "def" rather than the one from data-default-class #194
Comments
If we are rolling our own, does it make sense to name it something else too? Maybe It may also be better to do two breaking releases back-to-back in hope that some people will have skipped the .3 release? |
Fixes google#194. `data-default` is problematic since it's (1) lawless and (2) creeps into places it's not really intended for; e.g., using it for an integer value instead of an explicit 0. But protobufs *do* have a useful law, namely, `encodeMessage def == ""`. This change makes `Data.ProtoLens.Message` (and thus `Data.ProtoLens`, which reexports it): - Add a `defaultMessage` method to `Message`. - Redefine `def = defaultMessage` for convenience. I'm not convinced this is the best long-term UX; suggestions welcome.
Fixes google#194. `data-default` is problematic since it's (1) lawless and (2) creeps into places it's not really intended for; e.g., using it for an integer value instead of an explicit 0. But protobufs *do* have a useful law, namely, `encodeMessage def == ""`. This change makes `Data.ProtoLens.Message` (and thus `Data.ProtoLens`, which reexports it): - Add a `defaultMessage` method to `Message`. - Redefine `def = defaultMessage` for convenience. I'm not convinced this is the best long-term UX; suggestions welcome.
Fixes google#194. `data-default` is problematic since it's (1) lawless and (2) creeps into places it's not really intended for; e.g., using it for an integer value instead of an explicit 0. But protobufs *do* have a useful law, namely, `encodeMessage def == ""`. Before this change, the `Message` class had: ``` class Data.Default.Class.Default a => Message a where ... ``` After this change: ``` class Message a where defMessage :: a ... ``` We also provide a module `Data.ProtoLens.Default` which exports `def = defMessage`, to make it easier to convert old code. Also bumps versions; in particular, `proto-lens` is now at `v0.4`.
Fixes google#194. `data-default` is problematic since it's (1) lawless and (2) creeps into places it's not really intended for; e.g., using it for an integer value instead of an explicit 0. But protobufs *do* have a useful law, namely, `encodeMessage def == ""`. Before this change, the `Message` class had: ``` class Data.Default.Class.Default a => Message a where ... ``` After this change: ``` class Message a where defMessage :: a ... ``` We also provide a module `Data.ProtoLens.Default` which exports `def = defMessage`, to make it easier to convert old code. Also bumps versions; in particular, `proto-lens` is now at `v0.4`.
Fixes #194. `data-default` is problematic since it's (1) lawless and (2) creeps into places it's not really intended for; e.g., using it for an integer value instead of an explicit 0. But protobufs *do* have a useful law, namely, `encodeMessage def == ""`. Before this change, the `Message` class had: ``` class Data.Default.Class.Default a => Message a where ... ``` After this change: ``` class Message a where defMessage :: a ... ``` We also provide a module `Data.ProtoLens.Default` which exports `def = defMessage`, to make it easier to convert old code. Also bumps versions; in particular, `proto-lens` is now at `v0.4`.
Just chiming in here, |
Fixes google#194. `data-default` is problematic since it's (1) lawless and (2) creeps into places it's not really intended for; e.g., using it for an integer value instead of an explicit 0. But protobufs *do* have a useful law, namely, `encodeMessage def == ""`. Before this change, the `Message` class had: ``` class Data.Default.Class.Default a => Message a where ... ``` After this change: ``` class Message a where defMessage :: a ... ``` We also provide a module `Data.ProtoLens.Default` which exports `def = defMessage`, to make it easier to convert old code. Also bumps versions; in particular, `proto-lens` is now at `v0.4`.
Fixes google#194. `data-default` is problematic since it's (1) lawless and (2) creeps into places it's not really intended for; e.g., using it for an integer value instead of an explicit 0. But protobufs *do* have a useful law, namely, `encodeMessage def == ""`. Before this change, the `Message` class had: ``` class Data.Default.Class.Default a => Message a where ... ``` After this change: ``` class Message a where defMessage :: a ... ``` We also provide a module `Data.ProtoLens.Default` which exports `def = defMessage`, to make it easier to convert old code. Also bumps versions; in particular, `proto-lens` is now at `v0.4`.
Fixes google#194. `data-default` is problematic since it's (1) lawless and (2) creeps into places it's not really intended for; e.g., using it for an integer value instead of an explicit 0. But protobufs *do* have a useful law, namely, `encodeMessage def == ""`. Before this change, the `Message` class had: ``` class Data.Default.Class.Default a => Message a where ... ``` After this change: ``` class Message a where defMessage :: a ... ``` We also provide a module `Data.ProtoLens.Default` which exports `def = defMessage`, to make it easier to convert old code. Also bumps versions; in particular, `proto-lens` is now at `v0.4`.
The
data-default-class
package is...somewhat controversial. The main criticism is thatdef
doesn't satisfy any laws, so tends to be abused. See for example the following haskell-cafe thread: https://mail.haskell.org/pipermail/haskell-cafe/2018-May/129053.htmlIndeed, from our experience using
proto-lens
on a larger team, we've found thatdata-default
creeps into places it's not really intended for; e.g., using it for an integer value instead of an explicit0
.However, for protobufs we do have a useful law, namely,
encodeMessage def == ""
.Note that the
proto-lens
library already reexportsdef
directly: (Data.ProtoLens.Message
andData.ProtoLens
)I propose the following changes:
Remove all our dependencies on
data-default-class
(anddata-default
)Change the
Message
class to define its own methoddef
:Note that this is a breaking change, so it would cause a major version bump (i.e.,
proto-lens-0.4
). Given that we just released0.3
which has a fair bit of API churn, I'd probably rather wait a bit before doing another round. However, it should be fairly easy to write user code that's compatible with both versions, by writingimport Data.ProtoLens (def)
.The text was updated successfully, but these errors were encountered: