Copyright | João Cristóvão, 2014 |
---|---|

License | BSD3 |

Maintainer | jmacristovao@gmail.com |

Safe Haskell | Safe-Inferred |

Language | Haskell2010 |

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 a`Either`

`Foldable`

which is not a

, but where it makes sense to consider a`Monoid`

as an`Left`

`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 is`Monoid`

`1`

. Hardly qualifies as an`Empty`

or`Null`

value. For this reason no default implementation is provided for the

class. It's up to you to use`Monoid`

`(==) mempty`

instead.

The main use case for this package are boolean conditions,
namely the `if`

`then`

`else`

construct.

Bugs, suggestions and comments are most welcomed!

# Documentation

isNull ~ isEmpty ~ isInvalid?

`>>>`

True`isNull (Left 5)`

`>>>`

False`isNull ("abc" :: T.Text)`

`>>>`

False`isNull [""] -- see isNullN`

Typing causes arthritis. Alias for

.`isNull`

the logical negation of `isNull`

isNullN :: Foldable f => f a -> Bool Source

Nested isNull

`>>>`

False`isNullN (Just "abc")`

`>>>`

True`isNullN (Just "")`

`>>>`

True`isNullN (Nothing :: Maybe String)`

notNullN :: Foldable f => f a -> Bool Source

Nested isNotNull

isNullM :: Monad m => m a -> m Bool Source

Monadic isNull

`>>>`

[True]`isNullM [""]`

isNullNM :: (Monad m, Foldable f) => m (f a) -> m Bool Source

Monadic Nested isNull

(<\>) :: a -> a -> a infixl 3 Source

's `Alternative`

operator does not always operate as choice,
at least not in an intuitive way (for example with lists).
This one does:`<|>`

`>>>`

[2,3]`[2,3] <\> [4,5]`

`>>>`

[4,5]`[] <\> [4,5]`

`>>>`

[]`[] <\> []`