Skip to content

Commit eff3517

Browse files
Add nub constraint on Record Show instance (#269)
* Add nub constraint on Record Show instance * Update changelog * Copy Record.union and verify show on duplicate labels record fails * Remove show duplicate label test
1 parent a273e03 commit eff3517

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Breaking changes:
99
- Change Generic Rep's `NoConstructors` to newtype `Void` (#282 by @JordanMartinez)
1010
- Replaced polymorphic proxies with monomorphic `Proxy` (#281, #288 by @JordanMartinez)
1111
- Fix `signum zero` to return `zero` (#280 by @JordanMartinez)
12+
- Fix `Show` instance on records with duplicate labels by adding `Nub` constraint (#269 by @JordanMartinez)
1213

1314
New features:
1415

src/Data/Show.purs

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module Data.Show
66
) where
77

88
import Data.Symbol (class IsSymbol, reflectSymbol)
9+
import Prim.Row (class Nub)
910
import Prim.RowList as RL
1011
import Record.Unsafe (unsafeGet)
1112
import Type.Proxy (Proxy(..))
@@ -41,7 +42,11 @@ instance showArray :: Show a => Show (Array a) where
4142
instance showProxy :: Show (Proxy a) where
4243
show _ = "Proxy"
4344

44-
instance showRecord :: (RL.RowToList rs ls, ShowRecordFields ls rs) => Show (Record rs) where
45+
instance showRecord ::
46+
( Nub rs rs
47+
, RL.RowToList rs ls
48+
, ShowRecordFields ls rs
49+
) => Show (Record rs) where
4550
show record = case showRecordFields (Proxy :: Proxy ls) record of
4651
[] -> "{}"
4752
fields -> intercalate " " ["{", intercalate ", " fields, "}"]

0 commit comments

Comments
 (0)