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

Safe HaskellNone
LanguageHaskell2010

ADP.Fusion.Base.Classes

Synopsis

Documentation

data OutsideContext s Source

Constructors

OStatic s 
ORightOf s 
OFirstLeft s 
OLeftOf s 

data InsideContext s Source

Constructors

IStatic s 
IVariable s 

class Element x i where Source

During construction of the stream, we need to extract individual elements from symbols in production rules. An element in a stream is fixed by both, the type x of the actual argument we want to grab (say individual characters we parse from an input) and the type of indices i we use.

Elm data constructors are all eradicated during fusion and should never show up in CORE.

Associated Types

data Elm x i :: * Source

type RecElm x i :: * Source

type Arg x :: * Source

Methods

getArg :: Elm x i -> Arg x Source

getIdx :: Elm x i -> i Source

getOmx :: Elm x i -> i Source

getElm :: Elm x i -> RecElm x i Source

Instances

Element S i 
Element ls i => Element ((:!:) ls (TermSymbol a b)) i 
Element ls i => Element ((:!:) ls (Backtrack (ITbl mF arr j x) mF mB r)) i 
Element ls i => Element ((:!:) ls (ITbl m arr j x)) i 
Element ls i => Element ((:!:) ls (Backtrack (IRec mF i x) mF mB r)) i 
Element ls i => Element ((:!:) ls (IRec m i x)) i 
Element ls i => Element ((:!:) ls (Split uId splitType (Backtrack (ITbl mF arr j x) mF mB r))) i 
Element ls i => Element ((:!:) ls (Split uId splitType (ITbl m arr j x))) i 
Element ls i => Element ((:!:) ls (Chr r x)) i 
Element ls i => Element ((:!:) ls Deletion) i 
Element ls i => Element ((:!:) ls (Edge e)) i 
Element ls i => Element ((:!:) ls Epsilon) i 
Element ls i => Element ((:!:) ls (PeekIndex i)) i 
Element ls i => Element ((:!:) ls (Strng v x)) i 

class Monad m => MkStream m x i where Source

mkStream creates the actual stream of elements (Elm) that will be fed to functions on the left of the (<<<) operator. Streams work over all monads and are specialized for each combination of arguments x and indices i.

Methods

mkStream :: x -> Context i -> i -> i -> Stream m (Elm x i) Source

Instances

Monad m => MkStream m S Z 
Monad m => MkStream m S PointL 
Monad m => MkStream m S BitSet 
Monad m => MkStream m S Subword 
Monad m => MkStream m S (Outside Z) 
(Monad m, MkStream m S (Outside is), (~) * (Context (Outside ((:.) is PointL))) ((:.) (Context (Outside is)) (OutsideContext Int))) => MkStream m S (Outside ((:.) is PointL)) 
Monad m => MkStream m S (Outside PointL) 
Monad m => MkStream m S (Complement (BS2I First Last)) 
Monad m => MkStream m S (Outside (BS2I First Last)) 
Monad m => MkStream m S (Complement Subword) 
Monad m => MkStream m S (Outside Subword) 
(Monad m, MkStream m S is, (~) * (Context ((:.) is PointL)) ((:.) (Context is) (InsideContext Int))) => MkStream m S ((:.) is PointL) 
Monad m => MkStream m S (BS2I First Last) 
(Monad m, MkStream m S is, (~) * (Context ((:.) is Subword)) ((:.) (Context is) (InsideContext ()))) => MkStream m S ((:.) is Subword) 
(Monad m, MkStream m ls i, Element ls i, TerminalStream m (TermSymbol a b) i, TermStaticVar (TermSymbol a b) i) => MkStream m ((:!:) ls (TermSymbol a b)) i 
(Monad mB, Element ls PointL, PrimArrayOps arr PointL x, MkStream mB ls PointL) => MkStream mB ((:!:) ls (Backtrack (ITbl mF arr PointL x) mF mB r)) PointL 
(Monad m, Element ls PointL, PrimArrayOps arr PointL x, MkStream m ls PointL) => MkStream m ((:!:) ls (ITbl m arr PointL x)) PointL 
(Monad m, Element ls BitSet, PrimArrayOps arr BitSet x, MkStream m ls BitSet) => MkStream m ((:!:) ls (ITbl m arr BitSet x)) BitSet 
(Monad mB, FirstSecond ls (arr ((:.) ((:.) Z Subword) Subword) x), FirstSecondIdx ls (arr ((:.) ((:.) Z Subword) Subword) x) Subword, PrimArrayOps arr ((:.) ((:.) Z Subword) Subword) x, Element ls Subword, MkStream mB ls Subword, Show r) => MkStream mB ((:!:) ls (Backtrack (ITbl mF arr ((:.) ((:.) Z Subword) Subword) x) mF mB r)) Subword 
(Monad m, Element ls Subword, FirstSecond ls (arr ((:.) ((:.) Z Subword) Subword) x), FirstSecondIdx ls (arr ((:.) ((:.) Z Subword) Subword) x) Subword, PrimArrayOps arr ((:.) ((:.) Z Subword) Subword) x, MkStream m ls Subword, Show x) => MkStream m ((:!:) ls (ITbl m arr ((:.) ((:.) Z Subword) Subword) x)) Subword 
(Monad mB, Element ls Subword, MkStream mB ls Subword, PrimArrayOps arr Subword x) => MkStream mB ((:!:) ls (Backtrack (ITbl mF arr Subword x) mF mB r)) Subword 
(Monad m, Element ls Subword, PrimArrayOps arr Subword x, MkStream m ls Subword) => MkStream m ((:!:) ls (ITbl m arr Subword x)) Subword 
(Monad mB, Element ls Subword, MkStream mB ls Subword, SplitIxCol uId (SameSid uId (Elm ls Subword)) (Elm ls Subword), (~) * ((:.) (SplitIxTy uId (SameSid uId (Elm ls Subword)) (Elm ls Subword)) Subword) mix, PrimArrayOps arr ((:.) (SplitIxTy uId (SameSid uId (Elm ls Subword)) (Elm ls Subword)) Subword) x) => MkStream mB ((:!:) ls (Split uId Final (Backtrack (ITbl mF arr mix x) mF mB r))) Subword 
(Monad mB, Element ls Subword, MkStream mB ls Subword) => MkStream mB ((:!:) ls (Split uId Fragment (Backtrack (ITbl mF arr j x) mF mB r))) Subword 
(Monad m, Element ls Subword, MkStream m ls Subword, SplitIxCol uId (SameSid uId (Elm ls Subword)) (Elm ls Subword), (~) * ((:.) (SplitIxTy uId (SameSid uId (Elm ls Subword)) (Elm ls Subword)) Subword) mix, PrimArrayOps arr ((:.) (SplitIxTy uId (SameSid uId (Elm ls Subword)) (Elm ls Subword)) Subword) x) => MkStream m ((:!:) ls (Split uId Final (ITbl m arr mix x))) Subword 
(Monad m, Element ls Subword, MkStream m ls Subword) => MkStream m ((:!:) ls (Split uId Fragment (ITbl m arr j x))) Subword 
(Monad m, Element ls PointL, MkStream m ls PointL) => MkStream m ((:!:) ls (Chr r x)) PointL 
(Monad m, Element ls Subword, MkStream m ls Subword) => MkStream m ((:!:) ls (Chr r x)) Subword 
(Monad m, MkStream m ls PointL) => MkStream m ((:!:) ls Deletion) PointL 
(Monad m, MkStream m ls PointL) => MkStream m ((:!:) ls Epsilon) PointL 
(Monad m, MkStream m ls Subword) => MkStream m ((:!:) ls Epsilon) Subword 
(Monad m, Element ls PointL, MkStream m ls PointL) => MkStream m ((:!:) ls (Strng v x)) PointL 
(Monad m, Element ls Subword, MkStream m ls Subword) => MkStream m ((:!:) ls (Strng v x)) Subword

TODO If we use (IVariable mx) we might be able to request exactly the range we need!

(Monad mB, Element ls (Outside ((:.) is i)), TableStaticVar (Outside ((:.) is i)), TableIndices (Outside ((:.) is i)), MkStream mB ls (Outside ((:.) is i)), PrimArrayOps arr (Outside ((:.) is i)) x, Show ((:.) is i)) => MkStream mB ((:!:) ls (Backtrack (ITbl mF arr (Outside ((:.) is i)) x) mF mB r)) (Outside ((:.) is i)) 
(Monad m, Element ls (Outside ((:.) is i)), TableStaticVar (Outside ((:.) is i)), TableIndices (Outside ((:.) is i)), MkStream m ls (Outside ((:.) is i)), PrimArrayOps arr (Outside ((:.) is i)) x, Show ((:.) is i)) => MkStream m ((:!:) ls (ITbl m arr (Outside ((:.) is i)) x)) (Outside ((:.) is i)) 
(Monad mB, Element ls (Outside PointL), PrimArrayOps arr (Outside PointL) x, MkStream mB ls (Outside PointL)) => MkStream mB ((:!:) ls (Backtrack (ITbl mF arr (Outside PointL) x) mF mB r)) (Outside PointL) 
(Monad m, Element ls (Outside PointL), PrimArrayOps arr (Outside PointL) x, MkStream m ls (Outside PointL)) => MkStream m ((:!:) ls (ITbl m arr (Outside PointL) x)) (Outside PointL) 
(Monad m, Element ls (Complement Subword), PrimArrayOps arr (Outside Subword) x, MkStream m ls (Complement Subword)) => MkStream m ((:!:) ls (ITbl m arr (Outside Subword) x)) (Complement Subword) 
(Monad m, Element ls (Complement Subword), PrimArrayOps arr Subword x, MkStream m ls (Complement Subword)) => MkStream m ((:!:) ls (ITbl m arr Subword x)) (Complement Subword) 
(Monad m, Element ls (Outside Subword), PrimArrayOps arr Subword x, MkStream m ls (Outside Subword)) => MkStream m ((:!:) ls (ITbl m arr Subword x)) (Outside Subword) 
(Monad m, Element ls (Outside Subword), PrimArrayOps arr (Outside Subword) x, MkStream m ls (Outside Subword)) => MkStream m ((:!:) ls (ITbl m arr (Outside Subword) x)) (Outside Subword) 
(Monad m, Element ls (Outside PointL), MkStream m ls (Outside PointL)) => MkStream m ((:!:) ls (Chr r x)) (Outside PointL) 
(Monad m, Element ls (Outside Subword), MkStream m ls (Outside Subword)) => MkStream m ((:!:) ls (Chr r x)) (Outside Subword) 
(Monad m, Element ls (Outside PointL), MkStream m ls (Outside PointL)) => MkStream m ((:!:) ls Deletion) (Outside PointL) 
(Monad m, Element ls (Complement (BS2I First Last)), MkStream m ls (Complement (BS2I First Last))) => MkStream m ((:!:) ls (Edge f)) (Complement (BS2I First Last)) 
(Monad m, Element ls (Outside (BS2I First Last)), MkStream m ls (Outside (BS2I First Last))) => MkStream m ((:!:) ls (Edge f)) (Outside (BS2I First Last)) 
(Monad m, Element ls (Outside PointL), MkStream m ls (Outside PointL)) => MkStream m ((:!:) ls Epsilon) (Outside PointL) 
(Monad m, MkStream m ls (Outside Subword)) => MkStream m ((:!:) ls Epsilon) (Outside Subword) 
(Monad m, Element ls (Complement Subword), MkStream m ls (Complement Subword)) => MkStream m ((:!:) ls (PeekIndex (Complement Subword))) (Complement Subword) 
(Monad mB, Element ls ((:.) is i), TableStaticVar ((:.) is i), TableIndices ((:.) is i), MkStream mB ls ((:.) is i), PrimArrayOps arr ((:.) is i) x) => MkStream mB ((:!:) ls (Backtrack (ITbl mF arr ((:.) is i) x) mF mB r)) ((:.) is i) 
(Monad m, Element ls ((:.) is i), TableStaticVar ((:.) is i), TableIndices ((:.) is i), MkStream m ls ((:.) is i), PrimArrayOps arr ((:.) is i) x) => MkStream m ((:!:) ls (ITbl m arr ((:.) is i) x)) ((:.) is i) 
(Monad m, Element ls (BS2I First Last), PrimArrayOps arr (BS2I First Last) x, MkStream m ls (BS2I First Last), Show x) => MkStream m ((:!:) ls (ITbl m arr (BS2I First Last) x)) (BS2I First Last) 
(Monad m, Element ls (BS2I First Last), MkStream m ls (BS2I First Last)) => MkStream m ((:!:) ls (Edge e)) (BS2I First Last) 

class Build x where Source

Finally, we need to be able to correctly build together symbols on the right-hand side of the (<<<) operator.

The default makes sure that the last (or only) argument left over is correctly assigned a Z to terminate the symbol stack.

Minimal complete definition

Nothing

Associated Types

type Stack x :: * Source

Methods

build :: x -> Stack x Source

Instances

Build Deletion 
Build Epsilon 
Build (Edge e) 
Build (PeekIndex i) 
Build x => Build ((:!:) x y) 
Build (TermSymbol a b) 
Build (Chr r x) 
Build (Strng v x) 
Build (IRec m i x) 
Build (Split uId splitType synVar) 
Build (Backtrack t mF mB r) 
Build (ITbl m arr i x) 

data S Source

Similar to Z, but terminates an argument stack.

Constructors

S 

Instances

Eq S 
Show S 
Element S i 
FirstSecond S k 
GetIxs S i 
Monad m => MkStream m S Z 
Monad m => MkStream m S PointL 
Monad m => MkStream m S BitSet 
Monad m => MkStream m S Subword 
FirstSecondIdx S k i 
Monad m => MkStream m S (Outside Z) 
(Monad m, MkStream m S (Outside is), (~) * (Context (Outside ((:.) is PointL))) ((:.) (Context (Outside is)) (OutsideContext Int))) => MkStream m S (Outside ((:.) is PointL)) 
Monad m => MkStream m S (Outside PointL) 
Monad m => MkStream m S (Complement (BS2I First Last)) 
Monad m => MkStream m S (Outside (BS2I First Last)) 
Monad m => MkStream m S (Complement Subword) 
Monad m => MkStream m S (Outside Subword) 
(Monad m, MkStream m S is, (~) * (Context ((:.) is PointL)) ((:.) (Context is) (InsideContext Int))) => MkStream m S ((:.) is PointL) 
Monad m => MkStream m S (BS2I First Last) 
(Monad m, MkStream m S is, (~) * (Context ((:.) is Subword)) ((:.) (Context is) (InsideContext ()))) => MkStream m S ((:.) is Subword) 
SplitIxCol uId b (Elm S i) 
Show ix => Show (Elm S ix) 
data Elm S = ElmS !i !i 
type Arg S = Z 
type R S i = (:.) Z (i, i) 
type SplitIxTy uId b (Elm S i) = Z 

staticCheck :: Monad m => Bool -> Stream m a -> Stream m a Source

staticCheck acts as a static filter. If b is true, we keep all stream elements. If b is false, we discard all stream elements.

data StaticCheck a b Source

Constructors

CheckLeft a 
CheckRight b 

data TableConstraint Source

Constrains the behaviour of the memoizing tables. They may be EmptyOk if i==j is allowed (empty subwords or similar); or they may need NonEmpty indices, or finally they can be OnlyZero (only i==j allowed) which is useful in multi-dimensional casese.

Constructors

EmptyOk 
NonEmpty 
OnlyZero 

class ModifyConstraint t where Source

Methods

toNonEmpty :: t -> t Source

toEmpty :: t -> t Source

Instances