I'd explicitly add that if a value of `a` serializes to JSON as `null`,
it'll be deserialized as Nothing, and therefore this newtype may only be
used with types that never serialize as JSON `null`.


On Fri, Aug 22, 2014 at 2:16 PM, Niklas Hambuechen <[email protected]>
wrote:

> Signed-off-by: Niklas Hambuechen <[email protected]>
> ---
>  src/Ganeti/JSON.hs | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/Ganeti/JSON.hs b/src/Ganeti/JSON.hs
> index 5f58682..9aa9a2f 100644
> --- a/src/Ganeti/JSON.hs
> +++ b/src/Ganeti/JSON.hs
> @@ -424,6 +424,8 @@ class ArrayObject a where
>  -- | A Maybe newtype that allows for serialization more appropriate to the
>  -- semantics of Maybe and JSON in our calls. Does not produce needless
>  -- and confusing dictionaries.
> +--
> +-- In particular, `J.JSNull` corresponds to `Nothing`.
>  newtype MaybeForJSON a = MaybeForJSON { unMaybeForJSON :: Maybe a }
>    deriving (Show, Eq, Ord)
>  instance (J.JSON a) => J.JSON (MaybeForJSON a) where
> --
> 2.1.0.rc2.206.gedb03e5
>
>

Reply via email to