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

Safe HaskellNone
LanguageHaskell2010

ADP.Fusion.Core.Classes

Synopsis

Documentation

data InsideContext s Source #

Constructors

IStatic 

Fields

IVariable 

Fields

data ExtComplementContext s Source #

Needed for structures that have long-range interactions and "expand", like sets around edge boundaries: set edge set. requires the sets to be connected.

Constructors

CStatic s 
CVariable s 

class RuleContext i where Source #

Minimal complete definition

initialContext

Associated Types

type Context i :: * Source #

Methods

initialContext :: i -> Context i Source #

data family RunningIndex i :: * Source #

While we ostensibly use an index of type i we typically do not need every element of an i. For example, when looking at Subwords, we do not need both element of j:.k but only k. Also, inside grammars do need fewer moving indices than outside grammars.

TODO Sometimes, the actual RunningIndex ctors are not erased. This could be due to https://ghc.haskell.org/trac/ghc/ticket/2289. To test, we should transform RunningIndex into a type class to give us access to the left and right member, also we should create instances a la RunningIndex (is :. Subword I) = RiSwI !(RunningIndex is) !Int. Hopefully, these are completely erased.

Instances

Show (RunningIndex Z) Source # 
GetIndexGo (RunningIndex Z) (RunningIndex Z) EQ Source # 
GetIndexGo (RunningIndex ix) (RunningIndex Z) (CmpNat (ToNat (RunningIndex ix)) (ToNat (RunningIndex Z))) => GetIndexGo (RunningIndex ((:.) ix i)) (RunningIndex Z) GT Source # 
GetIndexGo (RunningIndex ix) (RunningIndex ((:.) my m)) (CmpNat (ToNat (RunningIndex ix)) (ToNat (RunningIndex ((:.) my m)))) => GetIndexGo (RunningIndex ((:.) ix i)) (RunningIndex ((:.) my m)) GT Source # 

Associated Types

type ResolvedIx (RunningIndex ((:.) ix i)) (RunningIndex ((:.) my m)) (GT :: Ordering) :: * Source #

GetIndexGo (RunningIndex ((:.) ix i)) (RunningIndex ((:.) my m)) EQ Source # 

Associated Types

type ResolvedIx (RunningIndex ((:.) ix i)) (RunningIndex ((:.) my m)) (EQ :: Ordering) :: * Source #

data RunningIndex Z Source # 
data RunningIndex (Unit t) Source # 
data RunningIndex (Unit t) = RiU
data RunningIndex (PointL I) Source # 
data RunningIndex (PointL O) Source # 
data RunningIndex (PointL C) Source # 
type ToNat (RunningIndex Z) Source # 
type ToNat (RunningIndex Z) = 0
type ToNat (RunningIndex ((:.) is i)) Source # 
type ToNat (RunningIndex ((:.) is i)) = (+) (ToNat (RunningIndex is)) 1
type ResolvedIx (RunningIndex Z) (RunningIndex Z) EQ Source # 
type ResolvedIx (RunningIndex ((:.) ix i)) (RunningIndex Z) GT Source # 
type ResolvedIx (RunningIndex ((:.) ix i)) (RunningIndex ((:.) my m)) GT Source # 
type ResolvedIx (RunningIndex ((:.) ix i)) (RunningIndex ((:.) my m)) EQ Source # 
data RunningIndex ((:.) is i) Source # 
data RunningIndex ((:.) is i) = !(RunningIndex is) :.: !(RunningIndex i)

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.

Minimal complete definition

getArg, getIdx, getElm

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 -> RunningIndex i Source #

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

Instances

Element S i Source # 

Associated Types

data Elm S i :: * Source #

type RecElm S i :: * Source #

type Arg S :: * Source #

Methods

getArg :: Elm S i -> Arg S Source #

getIdx :: Elm S i -> RunningIndex i Source #

getElm :: Elm S i -> RecElm S i Source #

((~) * s (Elm x0 i), Element x0 i) => Element (Term1 s) ((:.) Z i) Source # 

Associated Types

data Elm (Term1 s) ((:.) Z i) :: * Source #

type RecElm (Term1 s) ((:.) Z i) :: * Source #

type Arg (Term1 s) :: * Source #

Methods

getArg :: Elm (Term1 s) (Z :. i) -> Arg (Term1 s) Source #

getIdx :: Elm (Term1 s) (Z :. i) -> RunningIndex (Z :. i) Source #

getElm :: Elm (Term1 s) (Z :. i) -> RecElm (Term1 s) (Z :. i) Source #

((~) * s (Elm x0 i), Element x0 i) => Element (SynVar1 s) ((:.) Z i) Source # 

Associated Types

data Elm (SynVar1 s) ((:.) Z i) :: * Source #

type RecElm (SynVar1 s) ((:.) Z i) :: * Source #

type Arg (SynVar1 s) :: * Source #

Methods

getArg :: Elm (SynVar1 s) (Z :. i) -> Arg (SynVar1 s) Source #

getIdx :: Elm (SynVar1 s) (Z :. i) -> RunningIndex (Z :. i) Source #

getElm :: Elm (SynVar1 s) (Z :. i) -> RecElm (SynVar1 s) (Z :. i) Source #

Element ls i => Element ((:!:) ls (TermSymbol a b)) i Source # 

Associated Types

data Elm ((:!:) ls (TermSymbol a b)) i :: * Source #

type RecElm ((:!:) ls (TermSymbol a b)) i :: * Source #

type Arg ((:!:) ls (TermSymbol a b)) :: * Source #

Methods

getArg :: Elm (ls :!: TermSymbol a b) i -> Arg (ls :!: TermSymbol a b) Source #

getIdx :: Elm (ls :!: TermSymbol a b) i -> RunningIndex i Source #

getElm :: Elm (ls :!: TermSymbol a b) i -> RecElm (ls :!: TermSymbol a b) i Source #

Element ls i => Element ((:!:) ls (TwITblBt arr c j x mF mB r)) i Source # 

Associated Types

data Elm ((:!:) ls (TwITblBt arr c j x mF mB r)) i :: * Source #

type RecElm ((:!:) ls (TwITblBt arr c j x mF mB r)) i :: * Source #

type Arg ((:!:) ls (TwITblBt arr c j x mF mB r)) :: * Source #

Methods

getArg :: Elm (ls :!: TwITblBt arr c j x mF mB r) i -> Arg (ls :!: TwITblBt arr c j x mF mB r) Source #

getIdx :: Elm (ls :!: TwITblBt arr c j x mF mB r) i -> RunningIndex i Source #

getElm :: Elm (ls :!: TwITblBt arr c j x mF mB r) i -> RecElm (ls :!: TwITblBt arr c j x mF mB r) i Source #

Element ls i => Element ((:!:) ls (TwITbl m arr c j x)) i Source # 

Associated Types

data Elm ((:!:) ls (TwITbl m arr c j x)) i :: * Source #

type RecElm ((:!:) ls (TwITbl m arr c j x)) i :: * Source #

type Arg ((:!:) ls (TwITbl m arr c j x)) :: * Source #

Methods

getArg :: Elm (ls :!: TwITbl m arr c j x) i -> Arg (ls :!: TwITbl m arr c j x) Source #

getIdx :: Elm (ls :!: TwITbl m arr c j x) i -> RunningIndex i Source #

getElm :: Elm (ls :!: TwITbl m arr c j x) i -> RecElm (ls :!: TwITbl m arr c j x) i Source #

Element ls i => Element ((:!:) ls (TwIRecBt c u x mF mB r)) i Source # 

Associated Types

data Elm ((:!:) ls (TwIRecBt c u x mF mB r)) i :: * Source #

type RecElm ((:!:) ls (TwIRecBt c u x mF mB r)) i :: * Source #

type Arg ((:!:) ls (TwIRecBt c u x mF mB r)) :: * Source #

Methods

getArg :: Elm (ls :!: TwIRecBt c u x mF mB r) i -> Arg (ls :!: TwIRecBt c u x mF mB r) Source #

getIdx :: Elm (ls :!: TwIRecBt c u x mF mB r) i -> RunningIndex i Source #

getElm :: Elm (ls :!: TwIRecBt c u x mF mB r) i -> RecElm (ls :!: TwIRecBt c u x mF mB r) i Source #

Element ls i => Element ((:!:) ls (TwIRec m c u x)) i Source # 

Associated Types

data Elm ((:!:) ls (TwIRec m c u x)) i :: * Source #

type RecElm ((:!:) ls (TwIRec m c u x)) i :: * Source #

type Arg ((:!:) ls (TwIRec m c u x)) :: * Source #

Methods

getArg :: Elm (ls :!: TwIRec m c u x) i -> Arg (ls :!: TwIRec m c u x) Source #

getIdx :: Elm (ls :!: TwIRec m c u x) i -> RunningIndex i Source #

getElm :: Elm (ls :!: TwIRec m c u x) i -> RecElm (ls :!: TwIRec m c u x) i Source #

Element ls i => Element ((:!:) ls (Split uId splitType (TwITblBt arr c j x mF mB r))) i Source # 

Associated Types

data Elm ((:!:) ls (Split uId splitType (TwITblBt arr c j x mF mB r))) i :: * Source #

type RecElm ((:!:) ls (Split uId splitType (TwITblBt arr c j x mF mB r))) i :: * Source #

type Arg ((:!:) ls (Split uId splitType (TwITblBt arr c j x mF mB r))) :: * Source #

Methods

getArg :: Elm (ls :!: Split uId splitType (TwITblBt arr c j x mF mB r)) i -> Arg (ls :!: Split uId splitType (TwITblBt arr c j x mF mB r)) Source #

getIdx :: Elm (ls :!: Split uId splitType (TwITblBt arr c j x mF mB r)) i -> RunningIndex i Source #

getElm :: Elm (ls :!: Split uId splitType (TwITblBt arr c j x mF mB r)) i -> RecElm (ls :!: Split uId splitType (TwITblBt arr c j x mF mB r)) i Source #

Element ls i => Element ((:!:) ls (Split uId splitType (TwITbl m arr c j x))) i Source # 

Associated Types

data Elm ((:!:) ls (Split uId splitType (TwITbl m arr c j x))) i :: * Source #

type RecElm ((:!:) ls (Split uId splitType (TwITbl m arr c j x))) i :: * Source #

type Arg ((:!:) ls (Split uId splitType (TwITbl m arr c j x))) :: * Source #

Methods

getArg :: Elm (ls :!: Split uId splitType (TwITbl m arr c j x)) i -> Arg (ls :!: Split uId splitType (TwITbl m arr c j x)) Source #

getIdx :: Elm (ls :!: Split uId splitType (TwITbl m arr c j x)) i -> RunningIndex i Source #

getElm :: Elm (ls :!: Split uId splitType (TwITbl m arr c j x)) i -> RecElm (ls :!: Split uId splitType (TwITbl m arr c j x)) i Source #

Element ls i => Element ((:!:) ls (Chr r x)) i Source # 

Associated Types

data Elm ((:!:) ls (Chr r x)) i :: * Source #

type RecElm ((:!:) ls (Chr r x)) i :: * Source #

type Arg ((:!:) ls (Chr r x)) :: * Source #

Methods

getArg :: Elm (ls :!: Chr r x) i -> Arg (ls :!: Chr r x) Source #

getIdx :: Elm (ls :!: Chr r x) i -> RunningIndex i Source #

getElm :: Elm (ls :!: Chr r x) i -> RecElm (ls :!: Chr r x) i Source #

Element ls i => Element ((:!:) ls Deletion) i Source # 

Associated Types

data Elm ((:!:) ls Deletion) i :: * Source #

type RecElm ((:!:) ls Deletion) i :: * Source #

type Arg ((:!:) ls Deletion) :: * Source #

Element ls i => Element ((:!:) ls Edge) i Source # 

Associated Types

data Elm ((:!:) ls Edge) i :: * Source #

type RecElm ((:!:) ls Edge) i :: * Source #

type Arg ((:!:) ls Edge) :: * Source #

Methods

getArg :: Elm (ls :!: Edge) i -> Arg (ls :!: Edge) Source #

getIdx :: Elm (ls :!: Edge) i -> RunningIndex i Source #

getElm :: Elm (ls :!: Edge) i -> RecElm (ls :!: Edge) i Source #

Element ls i => Element ((:!:) ls Epsilon) i Source # 

Associated Types

data Elm ((:!:) ls Epsilon) i :: * Source #

type RecElm ((:!:) ls Epsilon) i :: * Source #

type Arg ((:!:) ls Epsilon) :: * Source #

Methods

getArg :: Elm (ls :!: Epsilon) i -> Arg (ls :!: Epsilon) Source #

getIdx :: Elm (ls :!: Epsilon) i -> RunningIndex i Source #

getElm :: Elm (ls :!: Epsilon) i -> RecElm (ls :!: Epsilon) i Source #

Element ls i => Element ((:!:) ls (PeekIndex i)) i Source # 

Associated Types

data Elm ((:!:) ls (PeekIndex i)) i :: * Source #

type RecElm ((:!:) ls (PeekIndex i)) i :: * Source #

type Arg ((:!:) ls (PeekIndex i)) :: * Source #

Methods

getArg :: Elm (ls :!: PeekIndex i) i -> Arg (ls :!: PeekIndex i) Source #

getIdx :: Elm (ls :!: PeekIndex i) i -> RunningIndex i Source #

getElm :: Elm (ls :!: PeekIndex i) i -> RecElm (ls :!: PeekIndex i) i Source #

Element ls i => Element ((:!:) ls (Strng v x)) i Source # 

Associated Types

data Elm ((:!:) ls (Strng v x)) i :: * Source #

type RecElm ((:!:) ls (Strng v x)) i :: * Source #

type Arg ((:!:) ls (Strng v x)) :: * Source #

Methods

getArg :: Elm (ls :!: Strng v x) i -> Arg (ls :!: Strng v x) Source #

getIdx :: Elm (ls :!: Strng v x) i -> RunningIndex i Source #

getElm :: Elm (ls :!: Strng v x) i -> RecElm (ls :!: Strng v x) i Source #

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.

Minimal complete definition

mkStream

Methods

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

Instances

(Monad m, MkStream m ls i, Element ls i, TermStaticVar (TermSymbol a b) i, TermStream m (TermSymbol a b) (Elm ls i) i) => MkStream m ((:!:) ls (TermSymbol a b)) i Source # 

Methods

mkStream :: (ls :!: TermSymbol a b) -> Context i -> i -> i -> Stream m (Elm (ls :!: TermSymbol a b) i) Source #

(Monad mB, Element ls ((:.) is i), TableStaticVar ((:.) us u) ((:.) cs c) ((:.) is i), AddIndexDense (Elm ls ((:.) is i)) ((:.) us u) ((:.) cs c) ((:.) is i), MkStream mB ls ((:.) is i), PrimArrayOps arr ((:.) us u) x) => MkStream mB ((:!:) ls (TwITblBt arr ((:.) cs c) ((:.) us u) x mF mB r)) ((:.) is i) Source # 

Methods

mkStream :: (ls :!: TwITblBt arr (cs :. c) (us :. u) x mF mB r) -> Context (is :. i) -> (is :. i) -> (is :. i) -> Stream mB (Elm (ls :!: TwITblBt arr (cs :. c) (us :. u) x mF mB r) (is :. i)) Source #

(Monad m, Element ls ((:.) is i), TableStaticVar ((:.) us u) ((:.) cs c) ((:.) is i), AddIndexDense (Elm ls ((:.) is i)) ((:.) us u) ((:.) cs c) ((:.) is i), MkStream m ls ((:.) is i), PrimArrayOps arr ((:.) us u) x) => MkStream m ((:!:) ls (TwITbl m arr ((:.) cs c) ((:.) us u) x)) ((:.) is i) Source # 

Methods

mkStream :: (ls :!: TwITbl m arr (cs :. c) (us :. u) x) -> Context (is :. i) -> (is :. i) -> (is :. i) -> Stream m (Elm (ls :!: TwITbl m arr (cs :. c) (us :. u) x) (is :. i)) Source #

(Applicative mB, Monad mB, Element ls ((:.) is i), TableStaticVar ((:.) us u) ((:.) cs c) ((:.) is i), AddIndexDense (Elm ls ((:.) is i)) ((:.) us u) ((:.) cs c) ((:.) is i), MkStream mB ls ((:.) is i)) => MkStream mB ((:!:) ls (TwIRecBt ((:.) cs c) ((:.) us u) x mF mB r)) ((:.) is i) Source # 

Methods

mkStream :: (ls :!: TwIRecBt (cs :. c) (us :. u) x mF mB r) -> Context (is :. i) -> (is :. i) -> (is :. i) -> Stream mB (Elm (ls :!: TwIRecBt (cs :. c) (us :. u) x mF mB r) (is :. i)) Source #

(Functor m, Monad m, Element ls ((:.) is i), TableStaticVar ((:.) us u) ((:.) cs c) ((:.) is i), AddIndexDense (Elm ls ((:.) is i)) ((:.) us u) ((:.) cs c) ((:.) is i), MkStream m ls ((:.) is i)) => MkStream m ((:!:) ls (TwIRec m ((:.) cs c) ((:.) us u) x)) ((:.) is i) Source # 

Methods

mkStream :: (ls :!: TwIRec m (cs :. c) (us :. u) x) -> Context (is :. i) -> (is :. i) -> (is :. i) -> Stream m (Elm (ls :!: TwIRec m (cs :. c) (us :. u) x) (is :. i)) Source #

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.

Associated Types

type Stack x :: * Source #

Methods

build :: x -> Stack x Source #

build :: Stack x ~ (S :!: x) => x -> Stack x Source #

Instances

Build Deletion Source # 

Associated Types

type Stack Deletion :: * Source #

Build Edge Source # 

Associated Types

type Stack Edge :: * Source #

Methods

build :: Edge -> Stack Edge Source #

Build Epsilon Source # 

Associated Types

type Stack Epsilon :: * Source #

Build (PeekIndex i) Source # 

Associated Types

type Stack (PeekIndex i) :: * Source #

Methods

build :: PeekIndex i -> Stack (PeekIndex i) Source #

Build x => Build ((:!:) x y) Source # 

Associated Types

type Stack ((:!:) x y) :: * Source #

Methods

build :: (x :!: y) -> Stack (x :!: y) Source #

Build (TermSymbol a b) Source # 

Associated Types

type Stack (TermSymbol a b) :: * Source #

Methods

build :: TermSymbol a b -> Stack (TermSymbol a b) Source #

Build (Chr r x) Source # 

Associated Types

type Stack (Chr r x) :: * Source #

Methods

build :: Chr r x -> Stack (Chr r x) Source #

Build (Strng v x) Source # 

Associated Types

type Stack (Strng v x) :: * Source #

Methods

build :: Strng v x -> Stack (Strng v x) Source #

Build (Split uId splitType synVar) Source # 

Associated Types

type Stack (Split uId splitType synVar) :: * Source #

Methods

build :: Split uId splitType synVar -> Stack (Split uId splitType synVar) Source #

Build (TwIRec m c i x) Source # 

Associated Types

type Stack (TwIRec m c i x) :: * Source #

Methods

build :: TwIRec m c i x -> Stack (TwIRec m c i x) Source #

Build (TwITbl m arr c i x) Source # 

Associated Types

type Stack (TwITbl m arr c i x) :: * Source #

Methods

build :: TwITbl m arr c i x -> Stack (TwITbl m arr c i x) Source #

Build (TwIRecBt c i x mF mB r) Source # 

Associated Types

type Stack (TwIRecBt c i x mF mB r) :: * Source #

Methods

build :: TwIRecBt c i x mF mB r -> Stack (TwIRecBt c i x mF mB r) Source #

Build (TwITblBt arr c i x mF mB r) Source # 

Associated Types

type Stack (TwITblBt arr c i x mF mB r) :: * Source #

Methods

build :: TwITblBt arr c i x mF mB r -> Stack (TwITblBt arr c i x mF mB r) Source #

data S Source #

Similar to Z, but terminates an argument stack.

Constructors

S 

Instances

Eq S Source # 

Methods

(==) :: S -> S -> Bool #

(/=) :: S -> S -> Bool #

Show S Source # 

Methods

showsPrec :: Int -> S -> ShowS #

show :: S -> String #

showList :: [S] -> ShowS #

Element S i Source # 

Associated Types

data Elm S i :: * Source #

type RecElm S i :: * Source #

type Arg S :: * Source #

Methods

getArg :: Elm S i -> Arg S Source #

getIdx :: Elm S i -> RunningIndex i Source #

getElm :: Elm S i -> RecElm S i Source #

SplitIxCol uId b (Elm S i) Source # 

Associated Types

type SplitIxTy (uId :: Symbol) (b :: Bool) (Elm S i) :: * Source #

Methods

splitIxCol :: Proxy Symbol uId -> Proxy Bool b -> Elm S i -> SplitIxTy uId b (Elm S i) Source #

Show (RunningIndex ix) => Show (Elm S ix) Source # 

Methods

showsPrec :: Int -> Elm S ix -> ShowS #

show :: Elm S ix -> String #

showList :: [Elm S ix] -> ShowS #

data Elm S Source # 
data Elm S = ElmS !(RunningIndex i)
type Arg S Source # 
type Arg S = Z
type SplitIxTy uId b (Elm S i) Source # 
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 Bool a 
CheckRight b 

staticCheck# :: Monad m => Int# -> Stream m a -> Stream m a Source #

data SLR z Source #

Constructors

SL !z !Int# 
SR !z 

data EmptyOk 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 

Instances

MinSize EmptyOk Source # 

Methods

minSize :: EmptyOk -> Int Source #

type TNE (TwITbl m arr EmptyOk i x) Source # 
type TNE (TwITbl m arr EmptyOk i x) = TwITbl m arr NonEmpty i x
type TE (TwITbl m arr EmptyOk i x) Source # 
type TE (TwITbl m arr EmptyOk i x) = TwITbl m arr EmptyOk i x
type TNE (TwITblBt arr EmptyOk i x mF mB r) Source # 
type TNE (TwITblBt arr EmptyOk i x mF mB r) = TwITblBt arr NonEmpty i x mF mB r
type TE (TwITblBt arr EmptyOk i x mF mB r) Source # 
type TE (TwITblBt arr EmptyOk i x mF mB r) = TwITblBt arr EmptyOk i x mF mB r

data NonEmpty Source #

Constructors

NonEmpty 

Instances

class MinSize c where Source #

Minimal complete definition

minSize

Methods

minSize :: c -> Int Source #

class ModifyConstraint t where Source #

TODO Rewrite to generalize easily over multi-dim cases.

Minimal complete definition

toNonEmpty, toEmpty

Associated Types

type TNE t :: * Source #

type TE t :: * Source #

Methods

toNonEmpty :: t -> TNE t Source #

toEmpty :: t -> TE t Source #