Maintainer | bastiaan.heeren@ou.nl |
---|---|

Stability | provisional |

Portability | portable (depends on ghc) |

Safe Haskell | None |

Language | Haskell98 |

- This module provides an interface to structure a collection of examples.
Examples can be taken from (lists of) concrete values, or from random
generators. Both types can be marked as test items. Examples can be assigned
a level of difficulty (ranging from very easy to very difficult). Test items
do not have a difficulty level. Examples can be grouped into sub-collections
and assigned an identifier. Use the
`Monoid`

operations for combining examples.

## Synopsis

- data Examples a
- example :: a -> Examples a
- exampleList :: [a] -> Examples a
- examplesFor :: Difficulty -> [a] -> Examples a
- examplesWithDifficulty :: [(Difficulty, a)] -> Examples a
- random :: Gen a -> Examples a
- group :: Id -> Examples a -> Examples a
- forTesting :: Examples a -> Examples a
- difficulty :: Difficulty -> Examples a -> Examples a
- veryEasy :: Examples a -> Examples a
- easy :: Examples a -> Examples a
- medium :: Examples a -> Examples a
- difficult :: Examples a -> Examples a
- veryDifficult :: Examples a -> Examples a
- isEmpty :: Examples a -> Bool
- size :: Examples a -> Int
- flatten :: Examples a -> Examples a
- groups :: Examples a -> [(Id, Examples a)]
- topLevelExamples :: Examples a -> [(Maybe Difficulty, a)]
- topLevelRandoms :: Examples a -> [(Maybe Difficulty, Gen a)]
- topLevelTests :: Examples a -> [a]
- topLevelRandomTests :: Examples a -> [Gen a]
- allExamples :: Examples a -> [(Maybe Difficulty, a)]
- allRandoms :: Examples a -> [(Maybe Difficulty, Gen a)]
- allTests :: Examples a -> [a]
- allRandomTests :: Examples a -> [Gen a]
- data Difficulty
- = VeryEasy
- | Easy
- | Medium
- | Difficult
- | VeryDifficult

- readDifficulty :: String -> Maybe Difficulty

# Examples type

# Constructing examples

exampleList :: [a] -> Examples a Source #

List of examples

examplesFor :: Difficulty -> [a] -> Examples a Source #

List of examples with the same difficulty

examplesWithDifficulty :: [(Difficulty, a)] -> Examples a Source #

List of examples with their own difficulty

forTesting :: Examples a -> Examples a Source #

Turn examples (and random generators) into tests (and test generators)

# Assigning difficulty

difficulty :: Difficulty -> Examples a -> Examples a Source #

Assign difficulty (to all items without a difficulty level)

veryDifficult :: Examples a -> Examples a Source #

# Transformations and queries

topLevelExamples :: Examples a -> [(Maybe Difficulty, a)] Source #

Top-level examples

topLevelRandoms :: Examples a -> [(Maybe Difficulty, Gen a)] Source #

Top-level random generators

topLevelTests :: Examples a -> [a] Source #

Top-level test cases

topLevelRandomTests :: Examples a -> [Gen a] Source #

Top-level test generators

allExamples :: Examples a -> [(Maybe Difficulty, a)] Source #

All examples (also in groups)

allRandoms :: Examples a -> [(Maybe Difficulty, Gen a)] Source #

All random generators (also in groups)

allRandomTests :: Examples a -> [Gen a] Source #

All test generators (also in groups)

# Difficulty type

data Difficulty Source #

## Instances

readDifficulty :: String -> Maybe Difficulty Source #

Parser for difficulty levels, which ignores non-alpha charactes (including spaces) and upper/lower case distinction.