Maintainer | [email protected] |
---|---|
Safe Haskell | None |
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 aEither
Foldable
which is not a
, but where it makes sense to consider aMonoid
as anLeft
Null
value. While this is not strictly true, the
option 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
-
Product
instance isMonoid
1
. Hardly qualifies as anEmpty
orNull
value. For this reason no default implementation is provided for the
class. It's up to you to useMonoid
(==) mempty
instead.
This class is suitable for use with GeneralizedNewtypeDeriving
,
thanks to the precious help of Ivan Miljenovic.
Bugs, suggestions and comments are most welcomed!
Documentation
Methods
isNull ~ isEmpty ~ isInvalid?
>>>
isNull (Left 5)
True
>>>
isNull ("abc" :: T.Text)
False
>>>
isNull [""] -- see isNullN
False