| Maintainer | jmacristovao@gmail.com |
|---|---|
| Safe Haskell | Safe-Inferred |
Data.IsNull
Description
A typeclass to determine if a given value is null.
Strongly inspired by mono-traversable but with a simpler goal: supporting IsNull and nested IsNull operations.
While the function is equivalent to isNull(==) mempty for most of
the instances, not all s are monoids,
and not all monoids Foldable means null:
mempty
-
is an example of aEitherFoldablewhich is not a, but where it makes sense to consider aMonoidas anLeftNullvalue. While this is not strictly true, theoption does carries a value, we take the more liberal approach: Empty ~ Null ~ Invalid Value. If you need proper type reasoning, you should not be using this package, just regular pattern matching instead.Left -
Productinstance isMonoid1. Hardly qualifies as anEmptyorNullvalue. For this reason no default implementation is provided for theclass. It's up to you to useMonoid(==) memptyinstead.
The main use case for this package are boolean conditions,
namely the if then else construct.
Bugs, suggestions and comments are most welcomed!
Documentation
Methods
isNull ~ isEmpty ~ isInvalid?
>>>isNull (Left 5)True
>>>isNull ("abc" :: T.Text)False
>>>isNull [""] -- see isNullNFalse
Typing causes arthritis. Alias for .
isNull
the logical negation of isNull
isNullN :: Foldable f => f a -> BoolSource
Nested isNull
>>>isNullN (Just "abc")False
>>>isNullN (Just "")True
>>>isNullN (Nothing :: Maybe String)True
notNullN :: Foldable f => f a -> BoolSource
Nested isNotNull
isNullM :: Monad m => m a -> m BoolSource
Monadic isNull
>>>isNullM [""][True]
isNullNM :: (Monad m, Foldable f) => m (f a) -> m BoolSource
Monadic Nested isNull