Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generalized fusion system for grammars.
This module re-exports only the core functionality.
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.
Synopsis
- data StreamAppend a b
- (<<<) :: forall k m initCtx symbols i b. (Monad m, Build symbols, Element (Stack symbols) i, Apply (Arg (Stack symbols) -> b), initCtx ~ InitialContext i, MkStream m initCtx (Stack symbols) i) => Fun (Arg (Stack symbols) -> b) -> symbols -> LimitType i -> i -> Stream m b
- (|||) :: Monad m => (t1 -> t2 -> Stream m a) -> (t1 -> t2 -> Stream m a) -> t1 -> t2 -> Stream m a
- streamappend :: Monad m => Stream m a -> Stream m a -> Stream m a
- (...) :: (t1 -> t2 -> t3) -> (t3 -> t4) -> t1 -> t2 -> t4
- (~~) :: a -> b -> Pair a b
- (%) :: a -> b -> Pair a b
- module ADP.Fusion.Core.Apply
- module ADP.Fusion.Core.Classes
- data family Elm x i :: *
- type PRI is i = Proxy (RunningIndex (is :. i))
- type TermStreamContext m (pos :: k) ts s x0 sixty is i = (Monad m, TermStream m pos ts s is, GetIndex (RunningIndex sixty) (RunningIndex (is :. i)), GetIx (RunningIndex sixty) (RunningIndex (is :. i)) ~ RunningIndex i, Element x0 sixty, s ~ Elm x0 sixty)
- newtype Term1 s = Term1 s
- class TermStream m pos t s i where
- data TermState s i e = TState !s !(RunningIndex i) !e
- class TableStaticVar pos minSize tableIx ix where
- tableStreamIndex :: Proxy pos -> minSize -> LimitType tableIx -> ix -> ix
- class TermStaticVar pos sym ix where
- termStreamIndex :: Proxy pos -> sym -> ix -> ix
- termStaticCheck :: Proxy pos -> sym -> LimitType ix -> ix -> Int# -> Int#
- type family TermArg x :: *
- data TermSymbol a b = a :| b
- data M = M
- addTermStream1 :: forall m pos t s i. (Monad m, TermStream m (Z :. pos) (TermSymbol M t) (Elm (Term1 s) (Z :. i)) (Z :. i)) => Proxy pos -> t -> LimitType i -> i -> Stream m s -> Stream m (s, TermArg t, RunningIndex i)
- elmTerm1 :: s -> i -> Elm (Term1 s) (Z :. i)
- module ADP.Fusion.Core.SynVar.Array.Type
- module ADP.Fusion.Core.SynVar.Axiom
- module ADP.Fusion.Core.SynVar.Backtrack
- module ADP.Fusion.Core.SynVar.FillTyLvl
- module ADP.Fusion.Core.SynVar.Indices
- module ADP.Fusion.Core.SynVar.Recursive.Type
- module ADP.Fusion.Core.SynVar.Split.Type
- module ADP.Fusion.Core.SynVar.TableWrap
- module ADP.Fusion.Core.Term.Chr
- module ADP.Fusion.Core.Term.Deletion
- module ADP.Fusion.Core.Term.Edge
- module ADP.Fusion.Core.Term.Epsilon
- module ADP.Fusion.Core.Term.MultiChr
- module ADP.Fusion.Core.Term.PeekIndex
- module ADP.Fusion.Core.Term.Str
- module ADP.Fusion.Core.TH
- module ADP.Fusion.Core.TyLvlIx
- data Stream (m :: Type -> Type) a where
- newtype Id a = Id {
- unId :: a
Documentation
data StreamAppend a b Source #
(<<<) :: forall k m initCtx symbols i b. (Monad m, Build symbols, Element (Stack symbols) i, Apply (Arg (Stack symbols) -> b), initCtx ~ InitialContext i, MkStream m initCtx (Stack symbols) i) => Fun (Arg (Stack symbols) -> b) -> symbols -> LimitType i -> i -> Stream m b infixl 8 Source #
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
.
(|||) :: Monad m => (t1 -> t2 -> Stream m a) -> (t1 -> t2 -> Stream m a) -> t1 -> t2 -> Stream m a infixl 7 Source #
Combine two RHSs to give a choice between parses.
(...) :: (t1 -> t2 -> t3) -> (t3 -> t4) -> t1 -> t2 -> t4 infixl 5 Source #
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 b infixl 9 Source #
This separator looks much paper "on paper" and is not widely used otherwise.
module ADP.Fusion.Core.Apply
module ADP.Fusion.Core.Classes
data family Elm x i :: * Source #
Instances
type TermStreamContext m (pos :: k) ts s x0 sixty is i = (Monad m, TermStream m pos ts s is, GetIndex (RunningIndex sixty) (RunningIndex (is :. i)), GetIx (RunningIndex sixty) (RunningIndex (is :. i)) ~ RunningIndex i, Element x0 sixty, s ~ Elm x0 sixty) Source #
Term MkStream
context
TODO prepare for deletion
Term TermStream
context
Term1 s |
class TermStream m pos t s i where Source #
termStream :: Proxy pos -> t -> LimitType i -> i -> Stream m (TermState s Z Z) -> Stream m (TermState s i (TermArg t)) Source #
Instances
TState !s !(RunningIndex i) !e |
class TableStaticVar pos minSize tableIx ix where Source #
:: Proxy pos | provide type-level information on if we are currently staticvariable etc |
-> minSize | Information on the minimal size of the corresponding table. |
-> LimitType tableIx | provide type-level information on the index structure of the table we
are looking at. This index structure might well be different than the
|
-> ix | current right-most index |
-> ix | right-most index for symbol to the left of us |
Instances
TableStaticVar (pos :: k) Z tableIx Z Source # | Index "0" for multi-dimensional syntactic variables. |
Defined in ADP.Fusion.Core.Multi | |
MinSize minSize => TableStaticVar (pos :: k) minSize u (PointL C) Source # | |
Defined in ADP.Fusion.PointL.Core | |
MinSize minSize => TableStaticVar (pos :: k) minSize u (PointL O) Source # | |
Defined in ADP.Fusion.PointL.Core | |
MinSize minSize => TableStaticVar (pos :: k) minSize u (PointL I) Source # | |
Defined in ADP.Fusion.PointL.Core | |
MinSize minSize => TableStaticVar (pos :: k) minSize u (PointR I) Source # | |
Defined in ADP.Fusion.PointR.Core | |
(TableStaticVar ps cs us is, TableStaticVar p c u i) => TableStaticVar (ps :. p :: Type) (cs :. c) (us :. u) (is :. i) Source # | |
class TermStaticVar pos sym ix where Source #
For multi-dimensional terminals we need to be able to calculate how the static/variable signal changes and if the index for the inner part needs to be modified.
termStreamIndex :: Proxy pos -> sym -> ix -> ix Source #
termStaticCheck :: Proxy pos -> sym -> LimitType ix -> ix -> Int# -> Int# Source #
Instances
type family TermArg x :: * Source #
Extracts the type of a multi-dimensional terminal argument.
Instances
data TermSymbol a b Source #
Terminal symbols are stacked together with a
tails and b
head.
a :| b infixl 2 |
Instances
Terminates a multi-dimensional terminal symbol stack.
addTermStream1 :: forall m pos t s i. (Monad m, TermStream m (Z :. pos) (TermSymbol M t) (Elm (Term1 s) (Z :. i)) (Z :. i)) => Proxy pos -> t -> LimitType i -> i -> Stream m s -> Stream m (s, TermArg t, RunningIndex i) Source #
TODO need t -> ElmType t
type function
TODO need to actually return an ElmType t
can do that instead of
returning u
!!!
module ADP.Fusion.Core.SynVar.Axiom
module ADP.Fusion.Core.Term.Chr
module ADP.Fusion.Core.Term.Edge
module ADP.Fusion.Core.Term.Epsilon
module ADP.Fusion.Core.Term.Str
module ADP.Fusion.Core.TH
module ADP.Fusion.Core.TyLvlIx
Identity monad
Instances
Monad Id | |
Functor Id | |
Applicative Id | |
(PrimArrayOps arr i x, MPrimArrayOps arr i x, isThisBigOrder ~ IsThisBigOrder bigOrder ts, isThisSmallOrder ~ IsThisSmallOrder smallOrder ts, isThisOrder ~ (isThisBigOrder && isThisSmallOrder), ThisSmallOrder bigOrder smallOrder isThisOrder ts i) => ThisSmallOrder bigOrder smallOrder True (ts :. TwITbl bo so Id arr c i x) i Source # | TODO generalize from |
(CountNumberOfCells n ts, Index i, PrimArrayOps arr i x, KnownNat n, KnownNat bo) => CountNumberOfCells n (ts :. TwITbl bo so Id arr c i x) Source # | |
Defined in ADP.Fusion.Core.SynVar.FillTyLvl |