|
|
|
|
|
|
| Synopsis |
|
|
|
|
| Types |
|
| newtype TermDir |
| Terms, ordered using direct lexicographic ordering.
That is, f(a, a) < f(a, b) < f(b, a) < f(b, b) | | Constructors | | | Instances | |
|
|
| newtype TermInv |
| Terms, ordered using inverse lexicographic ordering.
That is, f(a, a) < f(b, a) < f(a, b) < f(b, b) | | Constructors | | | Instances | |
|
|
| 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 :: !Bool | Flag 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 |
|
|
| matchPattern_hvl |
|
|
| 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 |
|
|
| 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 |
|
|
| 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 | | | -> Bool | whether 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) | | | => k | The key of the Set. | | -> e | The 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 |