-
Notifications
You must be signed in to change notification settings - Fork 108
Migration Guide
This page provides a guide for the changes necessary to switch between major versions of proto-lens.
In version 0.4, we have split proto-lens-protoc
into several packages:
-
proto-lens-protoc
just contains the binary -
proto-lens-runtime
contains the runtime libraries needed by generated code -
proto-lens-setup
enables building custom Setup scripts. It depends onproto-lens-protoc
.
To upgrade from v0.3 to v0.4:
- In the
setup-depends
field of thecustom-setup
clause, changeproto-lens-protoc
toproto-lens-setup
. - In the
build-depends
fields of libraries, tests and executables, changeproto-lens-protoc
toproto-lens-runtime
.
See the README for more detailed instructions.
In proto-lens
v0.3
and earlier, we used the def
message from Data.Default.Class
(from the data-default-class package) to construct
default protobuf messages:
class Data.Default.Class.Default a => Message a where
...
In version 0.4
, we have changed that to a custom method. (See #194 for the motivation).
The new API is:
class Message a where
defMessage :: a
Any previous code that tries to build a protobuf message with Data.Default.Class.def
will break. There are two ways to fix this:
-
Replace all uses of
def
withdefMessage
. That method is exported from bothData.ProtoLens
andData.ProtoLens.Message
. -
(Simpler, legacy option): use
Data.ProtoLens.Default.def
, which is defined asdef :: Message a => a def = defMessage
That is, change any module imports from
import Data.ProtoLens (def, encodeMessage, ...)
to
import Data.ProtoLens (encodeMessage, ...) import Data.ProtoLens.Default (def)
Starting in v0.4
, record constructors and raw record fields are no longer exported from generated modules.
For example, previously it was possible to construct a message with something like:
Foo { _Foo'bar = ..., _Foo'baz=...}
In v0.4, you should use the generated lenses, for example, either
defMessage & bar .~ ... & .~ baz .~ ...
or, with the OverloadedLabels
extension:
defMessage & #bar .~ ... & #baz .~ ...
Direct users of protoc-gen-haskell
(such as Bazel build rules) should change --no-reexports
flag to --no-runtime
.
proto-lens-protoc
now generates an explicit NFData
instance for each protocol buffer message type. Any previously-added (orphan) instances of NFData
should be removed.
Additionally, the Show
instance has been changed to use showMessageShort
rather than displaying the raw constructors. Note that, like showMessageShort
, it omits any fields which are set to the default values.