Safe Haskell | Safe-Infered |
---|

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 `

.

# Documentation

A type of non empty lists.

Typeable1 NonEmpty | |

Show a => Show (NonEmpty a) | |

Enumerable a => Enumerable (NonEmpty a) |

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