PermuteEffects-0.1.1: Permutations of effectful computations

Control.Applicative.Permute

Contents

Synopsis

Documentation

data Effects f a Source

A chain of effectful f-computations with final result a. Individual computations (lifted into Effects using one of the frequency combinators below) have their own result types, which fit together in standard Applicative fashion. Although these result types are existentially quantified, the computations can still be moved around within the list (see swap and firsts in the source code for examples). This allows their permutations to be computed.

Instances

Functor (Effects f)

Map over the final result type.

Applicative (Effects f)

pure represents the empty list of computations while <*> acts like ++.

perms :: forall f a. Alternative f => Effects f a -> f aSource

Build a tree (using <|> for branching) of all permutations of the computations. The tree shape allows permutations to share common prefixes. This allows clever computations to quickly prune away uninteresting branches of permutations.

Lifting computations

once :: f a -> Effects f aSource

Run the computation exactly once in each permutation.

opt :: f a -> Effects f (Maybe a)Source

Run the computation exactly zero or one times in each permutation.

atLeast :: Int -> f a -> Effects f [a]Source

Run the computation at least so many times in each permutation.

between :: Int -> Int -> f a -> Effects f [a]Source

Run the computation between so and so many times (inclusive) in each permutation.

exactly :: Int -> f a -> Effects f [a]Source

Run the computation exactly so many times in each permutation.

many :: f a -> Effects f [a]Source

Run the computation zero or more times in each permutation.

some :: f a -> Effects f [a]Source

Run the computation one or more times in each permutation.