@@ -31,6 +31,7 @@ import Control.Monad.Rec.Class (Step(..), tailRecM2)
3131import Control.Monad.ST (ST )
3232
3333import Data.Array as Array
34+ import Data.Eq (class Eq1 )
3435import Data.Array.ST (STArray , emptySTArray , runSTArray , pushSTArray )
3536import Data.Foldable (class Foldable , foldMap , foldl , foldr )
3637import Data.List (List )
@@ -45,7 +46,7 @@ import Partial.Unsafe (unsafePartial)
4546data Set a = Set (M.Map a Unit )
4647
4748-- | Create a set from a foldable structure.
48- fromFoldable :: forall f a . ( Foldable f , Ord a ) => f a -> Set a
49+ fromFoldable :: forall f a . Foldable f => Ord a => f a -> Set a
4950fromFoldable = foldl (\m a -> insert a m) empty
5051
5152-- | Convert a set to an unfoldable structure.
@@ -58,6 +59,9 @@ toList (Set m) = M.keys m
5859instance eqSet :: Eq a => Eq (Set a ) where
5960 eq (Set m1) (Set m2) = m1 == m2
6061
62+ instance eq1Set :: Eq1 Set where
63+ eq1 = eq
64+
6165instance showSet :: Show a => Show (Set a ) where
6266 show s = " (fromFoldable " <> show (toList s) <> " )"
6367
@@ -124,7 +128,7 @@ union :: forall a. Ord a => Set a -> Set a -> Set a
124128union (Set m1) (Set m2) = Set (m1 `M.union` m2)
125129
126130-- | Form the union of a collection of sets
127- unions :: forall f a . ( Foldable f , Ord a ) => f (Set a ) -> Set a
131+ unions :: forall f a . Foldable f => Ord a => f (Set a ) -> Set a
128132unions = foldl union empty
129133
130134-- | Form the set difference
0 commit comments