testing-feat-0.1: Functional enumeration for systematic and random testing

Safe HaskellSafe-Infered

Test.Feat.Modifiers

Description

Types with invariants. Currently these are mostly examples of how to define such types, suggestions on useful types are appreciated.

To use the invariant 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

Documentation

newtype NonEmpty a Source

A type of non empty lists.

Constructors

NonEmpty 

Fields

nonEmpty :: [a]
 

mkNonEmpty :: a -> [a] -> [a]Source

newtype Nat Source

A type of natural numbers.

Constructors

Nat 

Fields

nat :: Integer