| CARVIEW |
IsNull: A typeclass to determine if a given value is null.
A typeclass to determine if a given foldable type (or other) is empty ~ null ~ invalid. The definition is intentionally vague, to cover types from Either to Text and Sets.
[Skip to Readme]
Downloads
- IsNull-0.4.0.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
| Versions [RSS] | 0.3.0.0, 0.4.0.0 |
|---|---|
| Dependencies | base (>=4.5 && <4.8), base-compat (>=0.5 && <0.6), bytestring (>=0.10.0 && <1.0), containers (>=0.5 && <0.6), text (>=0.11.3 && <1.3) [details] |
| License | BSD-3-Clause |
| Author | João Cristóvão <jmacristovao@gmail.com> , Ivan Miljenovic <Ivan.Miljenovic@gmail.com> |
| Maintainer | jmacristovao@gmail.com |
| Uploaded | by jcristovao at 2014-06-19T15:38:51Z |
| Category | Data |
| Home page | https://github.com/jcristovao/IsNull |
| Source repo | head: git clone https://github.com/jcristovao/IsNull |
| Distributions | |
| Reverse Dependencies | 1 direct, 0 indirect [details] |
| Downloads | 2152 total (4 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating |
|
| Status | Docs available [build log] Successful builds reported [all 1 reports] |
Readme for IsNull-0.4.0.0
[back to package description]IsNull
A typeclass to determine if a given container is null.
Strongly inspired by mono-traversable, but with a simpler goal: supporting IsNull and nested IsNull operations.
Supported functions:
isNull :: a -> Bool
notNull :: a -> Bool
-- | Nested isNull
isNullN :: (Foldable f) => f a -> Bool
-- | Monadic isNull
isNullM :: Monad m => m a -> m Bool
-- | Monadic Nested isNull
isNullNM :: (Monad m, Foldable f) => m (f a) -> m Bool
-- | Alternative <|> operator does not always operate as choice,
-- at least not in an intuitive way (for example with lists).
-- This one does:
<\> :: a -> a -> a
The N stands for (non-recursive) nested, such that:
isNullN (Just "abc") == False
isNullN (Just "" ) == True
isNullN (Nothing ) == True
While the isNull function is equivalent to (==) mempty
for most of the instances, not all Foldables are monoids,
and not all monoids mempty means null:
-
Eitheris an example of aFoldablewhich is not aMonoid, but where it makes sense to consider aLeftas an 'Null' value. While this is not strictly true, theLeftoption 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. -
ProductMonoidinstance is1. Hardly qualifies as anEmptyorNullvalue. For this reason no default implementation is provided for theMonoidclass. It's up to you to use(==) memptyinstead.
Bugs, suggestions and comments are most welcomed!