ADPfusion-0.2.1.0: Efficient, high-level dynamic programming.

Safe HaskellNone

ADP.Fusion

Description

Generalized fusion system for grammars.

NOTE Symbols typically do not check bound data for consistency. If you, say, bind a terminal symbol to an input of length 0 and then run your grammar, you probably get errors, garbled data or random crashes. Such checks are done via asserts in non-production code.

TODO each combinator should come with a special outer check. Given some index (say (i,j), this can then check if i-const >= 0, or j+const<=n, or i+const<=j. That should speed up everything that uses GChr combinators. Separating out this check means that certain inner loops can run without any conditions and just jump.

Synopsis

Documentation

(<<<) :: (ValidIndex (Stack x) i, Build x, MkStream m (Stack x) i, Elms (Stack x) i, Apply (Arg (Stack x) -> a)) => Fun (Arg (Stack x) -> a) -> x -> i -> Stream m aSource

Apply a function to symbols on the RHS of a production rule. Builds the stack of symbols from xs using build, then hands this stack to mkStream together with the initial iniT telling mkStream that we are in the outer position. Once the stream has been created, we map getArg to get just the arguments in the stack, and finally apply the function f.

(<<#) :: (ValidIndex (Stack x) i, Build x, MkStream m (Stack x) i, Elms (Stack x) i, Apply (Arg (Stack x) -> m a)) => Fun (Arg (Stack x) -> m a) -> x -> i -> Stream m aSource

(|||) :: Monad m => (t -> Stream m a) -> (t -> Stream m a) -> t -> Stream m aSource

Combine two RHSs to give a choice between parses.

(...) :: (a -> b) -> (b -> c) -> a -> cSource

Applies the objective function h to a stream s. The objective function reduces the stream to a single optimal value (or some vector of co-optimal things).

(~~) :: a -> b -> Pair a bSource

Separator between RHS symbols.

(%) :: a -> b -> Pair a bSource

This separator looks much paper on paper and is not widely used otherwise.

check :: Monad m => (t -> Stream m a) -> (t -> Bool) -> t -> Stream m aSource

Additional outer check with user-given check function

chr :: Vector v r => v r -> GChr r rSource

Parses a single character.

chrLeft :: Vector v x => v x -> GChr (Maybe x, x) xSource

Parses a single character and returns the character to the left in a strict Maybe.

chrRight :: Vector v x => v x -> GChr (x, Maybe x) xSource

Parses a single character and returns the character to the right in a strict Maybe.

data MTbl i xs Source

Constructors

MTbl !(ENZ i) !xs 

Instances

(Monad m, PrimMonad m, Elms ls Subword, MkStream m ls Subword, MPrimArrayOps arr (:. Z Subword) x) => MkStream m (:!: ls (MTbl Subword (MutArr m (arr (:. Z Subword) x)))) Subword 
(Monad m, PrimMonad m, MPrimArrayOps arr (:. is i) x, Elms ls (:. is i), NonTermValidIndex (:. is i), TableIndices (:. is i), MkStream m ls (:. is i)) => MkStream m (:!: ls (MTbl (:. is i) (MutArr m (arr (:. is i) x)))) (:. is i) 
Build (MTbl i x) 
EmptyENZ (ENZ i) => EmptyTable (MTbl i xs) 
(ValidIndex ls Subword, Monad m, MPrimArrayOps arr (:. Z Subword) x) => ValidIndex (:!: ls (MTbl Subword (MutArr m (arr (:. Z Subword) x)))) Subword 
Elms ls Subword => Elms (:!: ls (MTbl Subword (MutArr m (arr (:. Z Subword) x)))) Subword 
(ValidIndex ls (:. is i), MPrimArrayOps arr (:. is i) x, NonTermValidIndex (:. is i)) => ValidIndex (:!: ls (MTbl (:. is i) (MutArr m (arr (:. is i) x)))) (:. is i) 
Elms ls (:. is i) => Elms (:!: ls (MTbl (:. is i) (MutArr m (arr (:. is i) x)))) (:. is i) 

data ENE Source

Constructors

EmptyT 
NonEmptyT 
ZeroT 

Instances

data None Source

Constructors

None 

Instances