lens / lens-aeson

Traversals and Prisms for Data.Aeson
MIT License
50 stars 18 forks source link

Add "nullIsNothing" #36

Open PaulJohnson opened 3 years ago

PaulJohnson commented 3 years ago

Implements #35. "nullIsNothing" converts a Value prism into one that accepts "null" as "Nothing".

paolino commented 3 years ago

Hi, while you are at that I would suggest to add the other natural null handler

nullIsDefault :: q -> Prism' Value q -> Prism' Value q
nullIsDefault q p = prism'
  do review p 
  do \case 
      Null -> Just q
      x -> preview p x 

Thanks for picking this up

PaulJohnson commented 3 years ago

OK, done.

ekmett commented 2 years ago

This is covered by non Null using the base lens library.