ideas-1.2: Feedback services for intelligent tutoring systems

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

Ideas.Common.Strategy.Combinators

Description

A collection of strategy combinators: all lifted to work on different data types

Synopsis

Documentation

(<*>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy aSource

Put two strategies in sequence (first do this, then do that)

(<|>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy aSource

Choose between the two strategies (either do this or do that)

(<%>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy aSource

Interleave two strategies

(<@>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy aSource

Alternate two strategies

succeed :: Strategy aSource

The strategy that always succeeds (without doing anything)

fail :: Strategy aSource

The strategy that always fails

atomic :: IsStrategy f => f a -> Strategy aSource

Makes a strategy atomic (w.r.t. parallel composition)

sequence :: IsStrategy f => [f a] -> Strategy aSource

Puts a list of strategies into a sequence

alternatives :: IsStrategy f => [f a] -> Strategy aSource

Combines a list of alternative strategies

interleave :: IsStrategy f => [f a] -> Strategy aSource

Merges a list of strategies (in parallel)

permute :: IsStrategy f => [f a] -> Strategy aSource

Allows all permutations of the list

many :: IsStrategy f => f a -> Strategy aSource

Repeat a strategy zero or more times (non-greedy)

many1 :: IsStrategy f => f a -> Strategy aSource

Apply a certain strategy at least once (non-greedy)

replicate :: IsStrategy f => Int -> f a -> Strategy aSource

Apply a strategy a certain number of times

option :: IsStrategy f => f a -> Strategy aSource

Apply a certain strategy or do nothing (non-greedy)

check :: (a -> Bool) -> Strategy aSource

Checks whether a predicate holds for the current term. The check is considered to be a minor step.

not :: IsStrategy f => f a -> Strategy aSource

Check whether or not the argument strategy cannot be applied: the result strategy only succeeds if this is not the case (otherwise it fails).

repeat :: IsStrategy f => f a -> Strategy aSource

Repeat a strategy zero or more times (greedy version of many)

repeat1 :: IsStrategy f => f a -> Strategy aSource

Apply a certain strategy at least once (greedy version of many1)

try :: IsStrategy f => f a -> Strategy aSource

Apply a certain strategy if this is possible (greedy version of option)

(|>) :: (IsStrategy f, IsStrategy g) => f a -> g a -> Strategy aSource

Left-biased choice: if the left-operand strategy can be applied, do so. Otherwise, try the right-operand strategy

while :: IsStrategy f => (a -> Bool) -> f a -> Strategy aSource

Repeat the strategy as long as the predicate holds

until :: IsStrategy f => (a -> Bool) -> f a -> Strategy aSource

Repeat the strategy until the predicate holds

multi :: (IsId l, IsStrategy f) => l -> f a -> LabeledStrategy aSource

Apply a strategy at least once, but collapse into a single step

exhaustive :: IsStrategy f => [f a] -> Strategy aSource

Apply the strategies from the list exhaustively (until this is no longer possible)

fix :: (Strategy a -> Strategy a) -> Strategy aSource

A fix-point combinator on strategies (to model recursion). Powerful (but dangerous) combinator

type DependencyGraph node key = (Graph, Vertex -> (node, key, [key]), key -> Maybe Vertex)Source

dependencyGraph :: IsStrategy f => DependencyGraph (f a) key -> Strategy aSource

Create a strategy from a dependency graph with strategies as nodes Does not check for cycles