Skip to content

Commit 47ff34f

Browse files
authored
Idiomatic Show instances for sets (#46)
* Idiomatic Show instances for sets * Update CHANGELOG.md
1 parent 0b540ea commit 47ff34f

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Notable changes to this project are documented in this file. The format is based
66

77
Breaking changes:
88
- Added support for PureScript 0.14 and dropped support for all previous versions (#35, #43)
9-
- Drop `Map`'s `Semigroup` and `Monoid` instances and provide unbiased instances via `SemigroupMap` newtype (#38)
9+
- Dropped `Map`'s `Semigroup` and `Monoid` instances and provide unbiased instances via a `SemigroupMap` newtype instead (#38)
10+
- Updated the `Show` instances for (non empty) sets (#46)
1011

1112
New features:
1213
- Added `Apply` instance for `Map` (#16)

src/Data/Set.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ instance eq1Set :: Eq1 Set where
7171
eq1 = eq
7272

7373
instance showSet :: Show a => Show (Set a) where
74-
show s = "(fromFoldable " <> show (toList s) <> ")"
74+
show s = "(fromFoldable " <> show (toUnfoldable s :: Array a) <> ")"
7575

7676
instance ordSet :: Ord a => Ord (Set a) where
7777
compare s1 s2 = compare (toList s1) (toList s2)

src/Data/Set/NonEmpty.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module Data.Set.NonEmpty
2626

2727
import Prelude hiding (map)
2828

29+
import Data.Array.NonEmpty (NonEmptyArray)
2930
import Data.Eq (class Eq1)
3031
import Data.Foldable (class Foldable)
3132
import Data.List (List, (:))
@@ -56,7 +57,7 @@ instance foldable1NonEmptySet :: Foldable1 NonEmptySet where
5657
foldl1 f = foldl1 f <<< (toUnfoldable1 :: forall a. NonEmptySet a -> NonEmptyList a)
5758

5859
instance showNonEmptySet :: Show a => Show (NonEmptySet a) where
59-
show s = "(fromFoldable1 " <> show (toUnfoldable1 s :: NonEmptyList a) <> ")"
60+
show s = "(fromFoldable1 " <> show (toUnfoldable1 s :: NonEmptyArray a) <> ")"
6061

6162
-- | Create a set with one element.
6263
singleton :: forall a. a -> NonEmptySet a

0 commit comments

Comments
 (0)