Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit c7bd77c

Browse files
committed
Merge pull request #21 from zudov/foldable-instance
Added Foldable instance
2 parents c6cf361 + 2ece220 commit c7bd77c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Data/Set.purs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import Data.Int ()
2828
import Data.Maybe
2929
import Data.Monoid
3030
import Data.Tuple
31-
import Data.Foldable (foldl)
31+
import Data.Foldable (Foldable, foldMap, foldl, foldr)
3232

3333
import Data.List (List(..))
3434

@@ -50,6 +50,11 @@ instance monoidSet :: (Ord a) => Monoid (Set a) where
5050
instance monoidSemigroup :: (Ord a) => Semigroup (Set a) where
5151
append = union
5252

53+
instance foldableSet :: Foldable Set where
54+
foldMap f = foldMap f <<< toList
55+
foldl f x = foldl f x <<< toList
56+
foldr f x = foldr f x <<< toList
57+
5358
-- | An empty set
5459
empty :: forall a. Set a
5560
empty = Set M.empty

0 commit comments

Comments
 (0)