Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handling nulls #35

Open
paolino opened this issue Jan 18, 2021 · 2 comments
Open

handling nulls #35

paolino opened this issue Jan 18, 2021 · 2 comments

Comments

@paolino
Copy link

paolino commented Jan 18, 2021

I'm using a lot this wrapper to parse maybes

nullIsNothing :: Prism' Value q -> Prism' Value (Maybe q)
nullIsNothing p = prism'
  do
    \case
      Nothing -> Null
      Just q -> review p q
  do
    \case
      Null -> Just Nothing
      x -> Just <$> preview p x

Would you insert it ?

@PaulJohnson
Copy link

PaulJohnson commented Aug 25, 2021

I'll second that. Pull request submitted. There may be a cleverer way of doing this with the existing lens combinators, but if so then I haven't figured it out.

@ekmett
Copy link
Member

ekmett commented Mar 8, 2022

non Null :: Iso' Value (Maybe Value)

can be composed with another prism (or lens or anything else, really)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants