testing-feat-0.4.0.2: Functional Enumeration of Algebraic Types

Test.Feat.Modifiers

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 Source

A type of non empty lists.

Constructors

 NonEmpty FieldsnonEmpty :: [a]

Instances

 Typeable1 NonEmpty Show a => Show (NonEmpty a) Enumerable a => Enumerable (NonEmpty a)

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

Numeric modifiers

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

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

Instances

 Infinite Integer

newtype Nat a Source

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

Constructors

 Nat Fieldsnat :: a

Instances

 Typeable1 Nat Eq a => Eq (Nat a) Ord a => Ord (Nat a) Show a => Show (Nat a) Infinite a => Enumerable (Nat a)

newtype NonZero a Source

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

Constructors

 NonZero FieldsnonZero :: a

Instances

 Typeable1 NonZero Eq a => Eq (NonZero a) Ord a => Ord (NonZero a) Show a => Show (NonZero a) (Infinite a, Enumerable a) => Enumerable (NonZero a)

Character and string modifiers

newtype Unicode Source

Any unicode character.

Constructors

 Unicode Fieldsunicode :: Char

Instances

 Eq Unicode Ord Unicode Show Unicode Typeable Unicode Enumerable Unicode

unicodes :: [Unicode] -> StringSource

Smart constructor for unicode strings.

newtype Printable Source

Printable ASCII characters

Constructors

 Printable Fieldsprintable :: Char

Instances

 Show Printable Typeable Printable Enumerable Printable

printables :: [Printable] -> StringSource

Smart constructor for printable ASCII strings