testing-feat-0.4.0.3: Functional Enumeration of Algebraic Types

Safe HaskellNone
LanguageHaskell98

Test.Feat.Modifiers

Contents

Description

Modifiers for types, i.e. newtype wrappers where the values satisfy some constraint (non-empty, positive etc.). Suggestions on useful types are appreciated.

To apply the modifiers types you can use the record label. For instance:

 data C a = C [a] [a] deriving Typeable
 instance Enumerable a => Enumerable (C a) where
    enumerate = unary $ funcurry $ 
      \xs ys -> C (nonEmpty xs) (nonEmpty ys)

Alternatively you can put everything in pattern postition:

 instance Enumerable a => Enumerable (C a) where
    enumerate = unary $ funcurry $ 
      \(Free (NonEmpty xs,NonEmpty ys)) -> C xs ys)

The first approach has the advantage of being usable with a point free style: \xs -> C (nonEmpty xs) . nonEmpty .

Synopsis

List modifiers

newtype NonEmpty a #

A type of non empty lists.

Constructors

NonEmpty 

Fields

Instances

mkNonEmpty :: (a, [a]) -> NonEmpty a #

Numeric modifiers

class (Typeable a, Integral a) => Infinite a #

A class of infinite precision integral types. Integer is the principal class member.

Instances

newtype Nat a #

A type of (infinite precision) natural numbers such that nat a >= 0 .

Constructors

Nat 

Fields

Instances

Eq a => Eq (Nat a) # 

Methods

(==) :: Nat a -> Nat a -> Bool #

(/=) :: Nat a -> Nat a -> Bool #

Ord a => Ord (Nat a) # 

Methods

compare :: Nat a -> Nat a -> Ordering #

(<) :: Nat a -> Nat a -> Bool #

(<=) :: Nat a -> Nat a -> Bool #

(>) :: Nat a -> Nat a -> Bool #

(>=) :: Nat a -> Nat a -> Bool #

max :: Nat a -> Nat a -> Nat a #

min :: Nat a -> Nat a -> Nat a #

Show a => Show (Nat a) # 

Methods

showsPrec :: Int -> Nat a -> ShowS #

show :: Nat a -> String #

showList :: [Nat a] -> ShowS #

Infinite a => Enumerable (Nat a) # 

Methods

enumerate :: Enumerate (Nat a) #

newtype NonZero a #

A type of (infinite precision) non-zero integers such that nonZero a /= 0 .

Constructors

NonZero 

Fields

Instances

Eq a => Eq (NonZero a) # 

Methods

(==) :: NonZero a -> NonZero a -> Bool #

(/=) :: NonZero a -> NonZero a -> Bool #

Ord a => Ord (NonZero a) # 

Methods

compare :: NonZero a -> NonZero a -> Ordering #

(<) :: NonZero a -> NonZero a -> Bool #

(<=) :: NonZero a -> NonZero a -> Bool #

(>) :: NonZero a -> NonZero a -> Bool #

(>=) :: NonZero a -> NonZero a -> Bool #

max :: NonZero a -> NonZero a -> NonZero a #

min :: NonZero a -> NonZero a -> NonZero a #

Show a => Show (NonZero a) # 

Methods

showsPrec :: Int -> NonZero a -> ShowS #

show :: NonZero a -> String #

showList :: [NonZero a] -> ShowS #

(Infinite a, Enumerable a) => Enumerable (NonZero a) # 

Character and string modifiers

newtype Unicode #

Any unicode character.

Constructors

Unicode 

Fields

unicodes :: [Unicode] -> String #

Smart constructor for unicode strings.

newtype Printable #

Printable ASCII characters

Constructors

Printable 

Fields

printables :: [Printable] -> String #

Smart constructor for printable ASCII strings