-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Execute a set of actions (e.g. parsers) in each possible order -- -- Sequence a set of Alternative actions in each possible order, based on -- "Parsing Permutation Phrases", by Arthur Baars, Andres Loeh and S. -- Doaitse Swierstra, Haskell Workshop 2001. This is particularly -- useful for constructing a parser for permutations of elements. This -- version has a slightly different interface from the paper. @package action-permutations @version 0.0.0.0 -- | Constructing an action as a choice between all the permutations of -- some given actions (e.g. parsers), based on "Parsing Permutation -- Phrases", by Arthur Baars, Andres Loeh and S. Doaitse Swierstra, -- Haskell Workshop 2001. -- -- This version has a slightly different interface from the paper. module Control.Applicative.Permutation -- | A representation of a permutation of actions of an Alternative -- type p. The value type of the composite action is a. -- -- Permutations are constructed from the primitives atom, -- optAtom and maybeAtom, and combined using the methods of -- Functor and Applicative. They are converted back to -- composite actions using runPerms and runPermsSep. -- -- The component actions of a permutation will be executed in each -- possible order, but the values they produce are always assembled in -- the order they occur in the program text, as in the following -- permutations of one, two or three component actions: -- -- -- -- The permutation is encoded as a tree, with the first action executed -- before the second selection is made. Thus failing actions, e.g. -- parsers, prune this tree. The size of the tree is exponential in the -- number of components, but it is constructed lazily. data Perms p a -- | A primitive permutation consisting of a single action. -- -- -- -- When building permutation parsers, the argument parser should not -- match the empty string: use optAtom or maybeAtom for -- optional elements. atom :: Alternative p => p a -> Perms p a -- | Like atom, but the action may be omitted from the permutation. -- -- -- -- When building permutation parsers, the argument parser should not -- match the empty string. optAtom :: Alternative p => a -> p a -> Perms p a -- | Like atom, but the action may be omitted from the permutation. -- -- -- -- When building permutation parsers, the argument parser should not -- match the empty string. maybeAtom :: Alternative p => p a -> Perms p (Maybe a) -- | Construct a permutation action. -- -- runPerms :: Alternative p => Perms p a -> p a -- | runPermsSep sep p is similar to runPerms -- p, except that the action sep is interleaved between -- atomic actions in each permutation. -- -- -- -- It is particularly useful in constructing permutation persers, where -- sep might be a parser for a comma or other separator. runPermsSep :: Alternative p => p b -> Perms p a -> p a instance Alternative p => Applicative (Branch p) instance Alternative p => Applicative (Perms p) instance Functor p => Functor (Branch p) instance Functor p => Functor (Perms p)