summaryrefslogtreecommitdiff
path: root/src/GF/Speech/Relation.hs
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2006-12-17 19:18:28 +0000
committerbringert <bringert@cs.chalmers.se>2006-12-17 19:18:28 +0000
commitc7df9f4167f7b554a93a216245a013e16cca420d (patch)
tree77be7e4fadb2c86f2583c58cf5e8d255a68829b8 /src/GF/Speech/Relation.hs
parent4e592d495e402bb8e73f860197315654c3958ae4 (diff)
Added still unused implementation of Moore's LCLR algorithm for left recursion elimination. Fixed top category generation for SRG (included LR-elimination-added categories before).
Diffstat (limited to 'src/GF/Speech/Relation.hs')
-rw-r--r--src/GF/Speech/Relation.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/GF/Speech/Relation.hs b/src/GF/Speech/Relation.hs
index a62b4b1a7..fe91716c6 100644
--- a/src/GF/Speech/Relation.hs
+++ b/src/GF/Speech/Relation.hs
@@ -12,12 +12,13 @@
-- A simple module for relations.
-----------------------------------------------------------------------------
-module GF.Speech.Relation (Rel, mkRel
+module GF.Speech.Relation (Rel, mkRel, mkRel'
, allRelated , isRelatedTo
, transitiveClosure
, reflexiveClosure, reflexiveClosure_
, symmetricClosure
, symmetricSubrelation, reflexiveSubrelation
+ , reflexiveElements
, equivalenceClasses
, isTransitive, isReflexive, isSymmetric
, isEquivalence
@@ -38,6 +39,11 @@ type Rel a = Map a (Set a)
mkRel :: Ord a => [(a,a)] -> Rel a
mkRel ps = relates ps Map.empty
+-- | Creates a relation from a list pairs of elements and the elements
+-- related to them.
+mkRel' :: Ord a => [(a,[a])] -> Rel a
+mkRel' xs = Map.fromListWith Set.union [(x,Set.fromList ys) | (x,ys) <- xs]
+
relToList :: Rel a -> [(a,a)]
relToList r = [ (x,y) | (x,ys) <- Map.toList r, y <- Set.toList ys ]