brendanhay / gogol

A comprehensive Google Services SDK for Haskell.
Other
280 stars 105 forks source link

firestore: `_vNullValue :: Maybe ValueNullValue` is Nothing for nulls #170

Open valyagolev opened 3 years ago

valyagolev commented 3 years ago

In firestore's Value', _vNullValue :: Maybe ValueNullValue is Nothing if the field is null. For the fields that exist in the firestore database, the value from gogol looks like this:

Value' {_vGeoPointValue = Nothing, _vBytesValue = Nothing, _vIntegerValue = Nothing, _vTimestampValue = Nothing, _vDoubleValue = Nothing, _vStringValue = Nothing, _vBooleanValue = Nothing, _vMapValue = Nothing, _vArrayValue = Nothing, _vReferenceValue = Nothing, _vNullValue = Nothing}.

The meaning of all those fields of Value' is apparently "exclusively valued as...". First of all, perhaps a sum type would actually work better here than having a subfield for every variant of the type?

But even if this approach is kept, since data ValueNullValue = NullValue has a constructor, I think it'd be more semantically coherent to have _vNullValue = Just NullValue in case the firestore value is null.