ContentsIndex
Grammar
Contents
Types
Reader and State Monads
Basic Constants and Operations
Queries
Boolean Queries
Search Queries
Simple Queries
Pattern Queries
Global Queries
Special Operations
Pretty Printing
Utilities
Synopsis
newtype TermDir = TermDir Term
newtype TermInv = TermInv Term
data Grammar = Gr {
labelToTerms :: !(Map Label (Set Term))
termDirToLabels :: !(Map TermDir (Set Label))
termInvToLabels :: !(Map TermInv (Set Label))
unknownIntersection :: !(Set (Label, Label))
changed :: !Bool
joined :: [(Label, Label)]
}
type GrReader = Reader Grammar
type GrState = State Grammar
actGr :: GrReader a -> GrState a
emptyGr :: Grammar
addToGr :: Label -> Term -> GrState Bool
clearGr :: GrState ()
changeGr :: GrState ()
touchLabel :: Label -> GrState ()
knowsLabel :: Label -> GrReader Bool
plainElem :: Label -> Term -> GrReader Bool
pureElem :: Label -> Term -> GrReader Bool
isEmptyPlainTerm :: Term -> GrReader Bool
labelsOfPlainTerm :: Term -> GrReader [Label]
plainTermsOfLabel :: Label -> GrReader [Term]
plainTermsOfLabel_h :: Label -> Head -> GrReader [Term]
matchPattern_h :: Head -> GrReader [(Label, Term)]
matchPattern_hlv :: Head -> Term -> GrReader [(Label, Term)]
matchPattern_hvl :: Head -> Term -> GrReader [(Label, Term)]
numberOfPlainTermsOfLabel :: Label -> GrReader Int
knownLabels :: GrReader [Label]
allKnownInfo :: GrReader [(Label, Term)]
joinLabels :: Label -> Label -> GrState ()
samePlainTermsOfLabels :: Label -> Label -> GrReader Bool
intersectingPlainTerms :: Bool -> Term -> Term -> GrReader Bool
intersectingLabels :: Bool -> Label -> Label -> GrReader Bool
addToUnknownIntersection :: (Label, Label) -> GrState ()
computeIntersection :: Bool -> GrState ()
closeUnderTransitivity :: GrState ()
closeUnderIntersection :: Bool -> Intersection -> GrState ()
pprGr :: Renamer -> GrReader String
pprSaveGr :: Renamer -> Bool -> GrReader String
augmentSet :: (Ord k, Ord e) => k -> e -> Map k (Set e) -> Map k (Set e)
split_GE :: Ord k => Map k a -> k -> Map k a
clampSet :: Ord e => e -> e -> Set e -> Set e
Types
newtype TermDir
Terms, ordered using direct lexicographic ordering. That is, f(a, a) < f(a, b) < f(b, a) < f(b, b)
Constructors
TermDir Term
Instances
Eq TermDir
Show TermDir
Ord TermDir
newtype TermInv
Terms, ordered using inverse lexicographic ordering. That is, f(a, a) < f(b, a) < f(a, b) < f(b, b)
Constructors
TermInv Term
Instances
Ord TermInv
Eq TermInv
Show TermInv
data Grammar
The data structure that holds all the information about the grammar.
Constructors
Gr
labelToTerms :: !(Map Label (Set Term))The label-to-set direct map.
termDirToLabels :: !(Map TermDir (Set Label))Maps every plain Term to the Labels of the sets the Term occurs in.
termInvToLabels :: !(Map TermInv (Set Label))Maps every plain Term to the Labels of the sets the Term occurs in.
unknownIntersection :: !(Set (Label, Label))The pairs of labels whose sets are still not known to intersect.
changed :: !BoolFlag set whenever the grammar is changed.
joined :: [(Label, Label)]User labels we joined.
Reader and State Monads
type GrReader = Reader Grammar
Read-only Grammar action
type GrState = State Grammar
Read-write Grammar action
actGr :: GrReader a -> GrState a
Transform a read-only action in a read-write one (which actually does not write anything).
Basic Constants and Operations
emptyGr :: Grammar
An empty Grammar, except for intersectionLabel.
addToGr :: Label -> Term -> GrState Bool
Add a plain Term to the set of a Label, updating all the maps. Return whether the 'Term was already in the Grammar.
clearGr :: GrState ()
Clear the changed flag.
changeGr :: GrState ()
Set the changed flag.
touchLabel :: Label -> GrState ()
If Label is not present in the Grammar, updates unknownIntersection to schedule the check for new intersections. Also assigns an empty set to the Label.
Queries
Boolean Queries
knowsLabel :: Label -> GrReader Bool
Checks whethera Label is present is the Grammar.
plainElem :: Label -> Term -> GrReader Bool
Check whether a plain Term belongs to the set of the given Label.
pureElem :: Label -> Term -> GrReader Bool
Check whether a pure Term belongs to the set of the given Label. The Term can be arbitrarily deep.
isEmptyPlainTerm :: Term -> GrReader Bool
Check whether a plain term can be expanded into a pure term, or instead it denotes an "empty" term set.
Search Queries
Simple Queries
labelsOfPlainTerm :: Term -> GrReader [Label]
Return all the occurrences of a plain Term.
plainTermsOfLabel :: Label -> GrReader [Term]
Return all the set of plain Terms of a Label.
plainTermsOfLabel_h :: Label -> Head -> GrReader [Term]
Return all the set of plain Terms of a Label matching h(X,...,Y). Arity can be /= 2.
Pattern Queries
matchPattern_h :: Head -> GrReader [(Label, Term)]
Return all the matches for a h(X,...,Y) pattern. Arity can be /= 2.
matchPattern_hlv
:: Head
h
-> Term
@lab
-> GrReader [(Label, Term)]
Return all the matches for a h(@lab,Y) pattern. Only arity 2.
matchPattern_hvl
:: Head
h
-> Term
@lab
-> GrReader [(Label, Term)]
Return all the matches for a h(X,@lab) pattern. Only arity 2.
Global Queries
numberOfPlainTermsOfLabel :: Label -> GrReader Int
Return the size of the set of a Label.
knownLabels :: GrReader [Label]
Return all the Labels that have a set in the Grammar.
allKnownInfo :: GrReader [(Label, Term)]
Return the whole Grammar as a list.
Special Operations
joinLabels
:: LabelThe Label that will hold the union set.
-> LabelThe Label that will disappear from the grammar.
-> GrState ()
Join two Labels.
samePlainTermsOfLabels :: Label -> Label -> GrReader Bool
Check whether two sets are equal.
intersectingPlainTerms :: Bool -> Term -> Term -> GrReader Bool
Check whether two plain terms intersect.
intersectingLabels :: Bool -> Label -> Label -> GrReader Bool
Check whether the sets of two Label intersect.
addToUnknownIntersection :: (Label, Label) -> GrState ()
Add the given pair to unknownIntersection.
computeIntersection
:: Boolwhether empty matters
-> GrState ()
Update the unknownIntersection and the set of intersectionLabel.
closeUnderTransitivity :: GrState ()

Close the sets under the transitivity rule, that is: (Warshall's variant)

 | L1 : X , L2 : L1 => L2 : X .

Also return whether the Grammar changed.

closeUnderIntersection :: Bool -> Intersection -> GrState ()

Intersect two sets according to the rule schema

 | L1 : f(X1,...) , L2 : f(X2,...) , @!Inters : cons(X1,X2) 
      => L : f(X1,...)

for each constructor f.

Pretty Printing
pprGr :: Renamer -> GrReader String
Pretty print a Grammar.
pprSaveGr
:: Renamer
-> Boolwhether to print Join info as well
-> GrReader String
Pretty print a Grammar in order to save it in a file. Prepend a @ to every '$' and '%' so that it is parsable again. Output is sorted in order to behave deterministically.
Utilities
augmentSet
:: (Ord k, Ord e)
=> kThe key of the Set.
-> eThe element to add to the Set.
-> Map k (Set e)
-> Map k (Set e)
Augment a set in a map.
split_GE :: Ord k => Map k a -> k -> Map k a
Restricts a Map to keys greater than or equal to a given key. (Similar to split)
clampSet :: Ord e => e -> e -> Set e -> Set e
Produced by Haddock version 0.6