git.iko.soy/rowtype-yoga/purescript-protobuf
on master help sign in
Update Common.purs
commit4c06b2b98676a1acea0dfd2cc4a9593c200cbabe authorJames Brock <jamesbrock@gmail.com> dateSun 30 May 2021, 21:53 (5 years ago) parent4c6f5a4
1 file changed+4−8
src/Protobuf/Common.purs+4−8
src/Protobuf/Common.purs+4−8
@@ -168,14 +168,10 @@ fromDefault x = if x==default then Nothing else Just x
168168
169169-- | Turns `Nothing` into a `default` value.
170170-- |
171−-- | The Protobuf spec requires that a field being set
172−-- | to zero (“default”) and a missing field are equivalent states.
173−-- | Because of this, there is
174−-- | no way to tell whether a missing field from a received message
175−-- | is really missing or if the sender meant that the field value is zero.
176−-- | We can use this function
177−-- | to manually choose whether we want
178−-- | a missing field to mean that it’s missing, or to mean that it’s zero.
171+-- | The Protobuf spec requires that a *no presence* field set
172+-- | to its “default” (zero) value must not be serialized to the wire.
173+-- | We can use this function to interpret
174+-- | a missing field as a “default” value.
179175toDefault :: forall a. Default a => Maybe a -> a
180176toDefault Nothing = default
181177toDefault (Just x) = x