You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per the discussion #133, a filter/withFilter method is useful to allow the use of pattern guards when applying post processing logic to DecodeResult instances. A simple example of when this is useful is in dealing with algebraic data types with case object instances. Such an instance might be encoded as a string in json, but when decoding json, the proper object must be selected based on the string value. Consider the following type State:
It became clear in chatting with @markhibberd that the best possible implementation of filter would provide a generic explanation while preserving the history. Therefore it should be in terms of #135 and thus requires #134.
The text was updated successfully, but these errors were encountered:
I'm not hugely bound to making a filter method that honours the needs of for comprehensions in Scala if requiring a message like the DecodeJson.validate better suits our needs.
Per the discussion #133, a
filter
/withFilter
method is useful to allow the use of pattern guards when applying post processing logic toDecodeResult
instances. A simple example of when this is useful is in dealing with algebraic data types with case object instances. Such an instance might be encoded as a string in json, but when decoding json, the proper object must be selected based on the string value. Consider the following typeState
:If
Open
is encoded as{"name": "open"}
, then we could use theState
extractor via a pattern guard (and thereforefilter
/withFilter
):It became clear in chatting with @markhibberd that the best possible implementation of
filter
would provide a generic explanation while preserving the history. Therefore it should be in terms of #135 and thus requires #134.The text was updated successfully, but these errors were encountered: