Commit ebb8dee8 authored by Camil Staps's avatar Camil Staps 🐧

Relax type contexts in Data.Set

parent 52f04c9c
Pipeline #40332 passed with stage
in 1 minute and 58 seconds
......@@ -310,11 +310,11 @@ maxView :: !.(Set a) -> .(Maybe (!a, !Set a))
* u = union xs ys
* elems = toList xs ++ toList ys
*/
union :: !u:(Set a) !u:(Set a) -> Set a | < a & == a
union :: !u:(Set a) !u:(Set a) -> Set a | < a
/**
* The union of a list of sets.
* @type !u:[v:(Set a)] -> Set a | < a & == a, [u <= v]
* @type !u:[v:(Set a)] -> Set a | < a, [u <= v]
*/
unions ts :== foldl union newSet ts
......@@ -329,7 +329,7 @@ unions ts :== foldl union newSet ts
* d = difference xs ys
* (xs`,ys`) = (toList xs, toList ys)
*/
difference :: !(Set a) !(Set a) -> Set a | < a & == a
difference :: !(Set a) !(Set a) -> Set a | < a
/**
* The intersection of two sets.
......@@ -344,13 +344,13 @@ difference :: !(Set a) !(Set a) -> Set a | < a & == a
* i = intersection xs ys
* (xs`,ys`) = (toList xs, toList ys)
*/
intersection :: !(Set a) !(Set a) -> Set a | < a & == a
intersection :: !(Set a) !(Set a) -> Set a | < a
/**
* The intersection of a list of sets.
* Elements of the result come from the first set
*/
intersections :: ![Set a] -> Set a | < a & == a
intersections :: ![Set a] -> Set a | < a
/**
* Filter all elements that satisfy the predicate.
......
......@@ -142,7 +142,7 @@ deleteMax Tip = Tip
* Union.
*--------------------------------------------------------------------*/
union :: !u:(Set a) !u:(Set a) -> Set a | < a & == a
union :: !u:(Set a) !u:(Set a) -> Set a | < a
union t1 Tip = t1
union t1 (Bin _ x Tip Tip) = insertR x t1
union (Bin _ x Tip Tip) t2 = insert x t2
......@@ -153,7 +153,7 @@ where
l1l2 = union l1 l2
r1r2 = union r1 r2
splitS :: !a !(Set a) -> (!Set a, !Set a) | <, == a
splitS :: !a !(Set a) -> (!Set a, !Set a) | < a
splitS _ Tip = (Tip,Tip)
splitS x (Bin _ y l r)
| x < y = let (lt,gt) = splitS x l in (lt, link y gt r)
......@@ -164,7 +164,7 @@ splitS x (Bin _ y l r)
* Difference
*--------------------------------------------------------------------*/
difference :: !(Set a) !(Set a) -> Set a | < a & == a
difference :: !(Set a) !(Set a) -> Set a | < a
difference Tip _ = Tip
difference t1 Tip = t1
difference t1 (Bin _ x l2 r2) = case split x t1 of
......@@ -179,17 +179,17 @@ difference t1 (Bin _ x l2 r2) = case split x t1 of
* Intersection
*--------------------------------------------------------------------*/
intersections :: ![Set a] -> Set a | < a & == a
intersections :: ![Set a] -> Set a | < a
intersections [t] = t
intersections [t:ts] = 'StdList'.foldl intersection t ts
intersections [] = abort "intersections called with []\n"
intersection :: !(Set a) !(Set a) -> Set a | < a & == a
intersection :: !(Set a) !(Set a) -> Set a | < a
intersection Tip _ = Tip
intersection _ Tip = Tip
intersection t1 t2 = hedgeInt NothingS NothingS t1 t2
hedgeInt :: !(MaybeS a) !(MaybeS a) !(Set a) !(Set a) -> Set a | < a & == a
hedgeInt :: !(MaybeS a) !(MaybeS a) !(Set a) !(Set a) -> Set a | < a
hedgeInt _ _ _ Tip = Tip
hedgeInt _ _ Tip _ = Tip
hedgeInt blo bhi (Bin _ x l r) t2
......@@ -253,7 +253,7 @@ fromList xs = 'StdList'.foldl ins newSet xs
empty or the key of the root is between @lo@ and @hi@.
--------------------------------------------------------------------*/
trim :: !(MaybeS a) !(MaybeS a) !(Set a) -> Set a | < a & == a
trim :: !(MaybeS a) !(MaybeS a) !(Set a) -> Set a | < a
trim NothingS NothingS t = t
trim (JustS lx) NothingS t = greater lx t
where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment