not package:universum
Deprecated: Don't use this function. Use maybeToRight
instead
Helper for lifting operations which require container to be not empty.
Performs given action over
NonEmpty list if given list is non
empty.
>>> whenNotNull [] $ \(b :| _) -> print (not b)
>>> whenNotNull [False,True] $ \(b :| _) -> print (not b)
True
Performs default
Applicative action if
Nothing is given.
Otherwise returns content of
Just pured to
Applicative.
>>> whenNothing Nothing [True, False]
[True,False]
>>> whenNothing (Just True) [True, False]
[True]
Performs default
Applicative action if
Nothing is given.
Do nothing for
Just. Convenient for discarding
Just
content.
>>> whenNothing_ Nothing $ putTextLn "Nothing!"
Nothing!
>>> whenNothing_ (Just True) $ putTextLn "Nothing!"
The
isNothing function returns
True iff its argument is
Nothing.
Examples
Basic usage:
>>> isNothing (Just 3)
False
>>> isNothing (Just ())
False
>>> isNothing Nothing
True
Only the outer constructor is taken into consideration:
>>> isNothing (Just Nothing)
False