packages feed

predicates (empty) → 0.1

raw patch · 3 files changed

+46/−0 lines, 3 filesdep +basesetup-changed

Dependencies added: base

Files

+ Data/Function/Predicate.hs view
@@ -0,0 +1,29 @@+{-# LANGUAGE UnicodeSyntax #-}++-- | Provides a couple of convenience functions to be used for forming predicates. +module Data.Function.Predicate+(is,isn't,equals)+where++-- |An example will explain this more than anything:+--+-- > listsLongerThan3Elements :: [[a]] -> [[a]]+-- > listsLongerThan3Elements = filter (length `is` (>3))+is :: (a → b) → (b → Bool) → (a → Bool)+is = flip (.)++-- |The inverse of 'is'.+--+-- > listsShorterThanFourElements = filter (length `isn't` (>3))+isn't :: (a → b) → (b → Bool) → (a → Bool)+isn't p x y = not $ (p `is` x) y++-- |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)+equals :: (Eq b) ⇒ (a → b) → b → a → Bool+equals p y x = p x == y
+ Setup.lhs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++> import Distribution.Simple+> main = defaultMain
+ predicates.cabal view
@@ -0,0 +1,13 @@+Name: predicates+Version: 0.1+Synopsis: A couple of convenience functions for forming predicates.+License: BSD3+Author: George Pollard+Maintainer: George Pollard <porges@porg.es>+Build-Depends: base+Exposed-modules: Data.Function.Predicate+Build-Type: Simple+Category: Combinators+Description: A couple of convenience functions for forming predicates (currently 'is', 'isn't', and 'equals'). Also my first library as a test ;)+Extensions: UnicodeSyntax+Cabal-Version: >= 1.2.3