ideas-1.8: Feedback services for intelligent tutoring systems

Maintainerbastiaan.heeren@ou.nl
Stabilityprovisional
Portabilityportable (depends on ghc)
Safe HaskellNone
LanguageHaskell98

Ideas.Common.Examples

Contents

Description

  • 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

Examples type

data Examples a Source #

Instances
Functor Examples Source # 
Instance details

Defined in Ideas.Common.Examples

Methods

fmap :: (a -> b) -> Examples a -> Examples b #

(<$) :: a -> Examples b -> Examples a #

Semigroup (Examples a) Source # 
Instance details

Defined in Ideas.Common.Examples

Methods

(<>) :: Examples a -> Examples a -> Examples a #

sconcat :: NonEmpty (Examples a) -> Examples a #

stimes :: Integral b => b -> Examples a -> Examples a #

Monoid (Examples a) Source # 
Instance details

Defined in Ideas.Common.Examples

Methods

mempty :: Examples a #

mappend :: Examples a -> Examples a -> Examples a #

mconcat :: [Examples a] -> Examples a #

Constructing examples

example :: a -> Examples a Source #

One example

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

random :: Gen a -> Examples a Source #

Use a random generator (from QuickCheck) as example generator

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)

Transformations and queries

isEmpty :: Examples a -> Bool Source #

Tests if there ar no examples

size :: Examples a -> Int Source #

Number of examples, including those in subgroups

flatten :: Examples a -> Examples a Source #

Flatten examples into one collection without subgroups

groups :: Examples a -> [(Id, Examples a)] Source #

Top-level groups

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)

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

All test cases (also in groups)

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

All test generators (also in groups)

Difficulty type

data Difficulty Source #

readDifficulty :: String -> Maybe Difficulty Source #

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