-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A data structure representing Relations on Sets. -- -- A library to model relationships between two objects that are -- subclasses of Ord. We use a two Maps that allows fast searching either -- by the key element or the value element. @package relation @version 0.4 -- | Relations are modeled as assciations between two elements. -- -- Relations offer efficient search for any of the two elements. -- -- Unlike Data.Map, an element ca be associated more than once. -- -- The two purposes of this structure are: -- --
    --
  1. Associating elements
  2. --
  3. Provide efficient searches for either of the two elements.
  4. --
-- -- Since neither map nor fold are implemented, you -- must convert the structure to a list to process sequentially. module Data.Relation -- | This implementation avoids using "S.Set (a,b)" because it it -- is necessary to search for an item without knowing both D and -- R. -- -- In S.Set, you must know both values to search. -- -- Thus, we have are two maps to updated together. -- --
    --
  1. Always be careful with the associated set of the key.
  2. --
  3. If you union two relations, apply union to the set of values.
  4. --
  5. If you subtract, take care when handling the set of values.
  6. --
-- -- As a multi-map, each key is asscoated with a Set of values v. -- -- We do not allow the associations with the empty Set. data Relation a b -- | size r returns the number of tuples in the relation. size :: Relation a b -> Int -- | True if the relation r is the empty relation. null :: Relation a b -> Bool -- | Construct a relation with no elements. empty :: Relation a b -- | The list must be formatted like: [(k1, v1), (k2, v2),..,(kn, vn)]. fromList :: (Ord a, Ord b) => [(a, b)] -> Relation a b -- | Builds a Relation consiting of an association between: -- x and y. singleton :: a -> b -> Relation a b -- | The Relation that results from the union of two relations: -- r and s. union :: (Ord a, Ord b) => Relation a b -> Relation a b -> Relation a b -- | Union a list of relations using the empty relation. unions :: (Ord a, Ord b) => [Relation a b] -> Relation a b -- | Intersection of two relations: a and b are related -- by intersection r s exactly when a and b -- are related by r and s. intersection :: (Ord a, Ord b) => Relation a b -> Relation a b -> Relation a b -- | Insert a relation x and y in the relation r -- insert :: (Ord a, Ord b) => a -> b -> Relation a b -> Relation a b -- | Delete an association in the relation. delete :: (Ord a, Ord b) => a -> b -> Relation a b -> Relation a b -- | The Set of values associated with a value in the domain. lookupDom :: Ord a => a -> Relation a b -> Set b -- | The Set of values associated with a value in the range. lookupRan :: Ord b => b -> Relation a b -> Set a -- | True if the element x exists in the domain of r . memberDom :: Ord a => a -> Relation a b -> Bool -- | True if the element exists in the range. memberRan :: Ord b => b -> Relation a b -> Bool -- | True if the relation contains the association x and -- y member :: (Ord a, Ord b) => a -> b -> Relation a b -> Bool -- | True if the relation does not contain the association -- x and y notMember :: (Ord a, Ord b) => a -> b -> Relation a b -> Bool -- | Builds a List from a Relation. toList :: Relation a b -> [(a, b)] -- | Returns the domain in the relation, as a Set, in its entirety. dom :: Relation a b -> Set a -- | Returns the range of the relation, as a Set, in its entirety. ran :: Relation a b -> Set b -- | Returns the converse of the relation. c :: Relation a b -> Relation b a -- | A compact set of sets the values of which can be Just (Set x) -- or Nothing. -- -- The cases of Nothing are purged. -- -- It is similar to concat. compactSet :: Ord a => Set (Set a) -> Set a -- |
--   ( Case a |> r b )
--   
(|$>) :: (Ord a, Ord b) => Set a -> Set b -> Relation a b -> Set b -- |
--   (Case b <| r a)
--   
(<$|) :: (Ord a, Ord b) => Set a -> Set b -> Relation a b -> Set a -- | Domain restriction for a relation. Modeled on z. (<|) :: (Ord a, Ord b) => Set a -> Relation a b -> Relation a b -- | Range restriction for a relation. Modeled on z. (|>) :: (Ord a, Ord b) => Relation a b -> Set b -> Relation a b instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Data.Relation.Relation a b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Data.Relation.Relation a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Data.Relation.Relation a b)