predicates-0.1: A couple of convenience functions for forming predicates.

Data.Function.Predicate

Description

Provides a couple of convenience functions to be used for forming predicates.

Synopsis

Documentation

is :: (a -> b) -> (b -> Bool) -> a -> BoolSource

An example will explain this more than anything:

 listsLongerThan3Elements :: [[a]] -> [[a]]
 listsLongerThan3Elements = filter (length `is` (>3))

isn't :: (a -> b) -> (b -> Bool) -> a -> BoolSource

The inverse of is.

 listsShorterThanFourElements = filter (length `isn't` (>3))

equals :: Eq b => (a -> b) -> b -> a -> BoolSource

This is is with a fixed equality condition.

Example:

 data Color = White | Black deriving (Eq)
 data ChessPiece = { color :: Color, name :: String }
 whitePieces = filter (color `equals` White)