Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ Breaking changes:
- Change Generic Rep's `NoConstructors` to newtype `Void` (#282 by @JordanMartinez)
- Replaced polymorphic proxies with monomorphic `Proxy` (#281, #288 by @JordanMartinez)
- Fix `signum zero` to return `zero` (#280 by @JordanMartinez)
- Fix `Show` instance on records with duplicate labels by adding `Nub` constraint (#269 by @JordanMartinez)

New features:

Bugfixes:
- Fix Record's `Show` instance when it has duplicate labels (#269 by @JordanMartinez)

Other improvements:
- Changed `unit`'s FFI representation from `{}` to `undefined` (#267 by @JordanMartinez)
Expand Down
8 changes: 7 additions & 1 deletion src/Data/Show.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Data.Show
) where

import Data.Symbol (class IsSymbol, reflectSymbol)
import Prim.Row (class Nub)
import Prim.RowList as RL
import Record.Unsafe (unsafeGet)
import Type.Proxy (Proxy(..))
Expand Down Expand Up @@ -41,7 +42,12 @@ instance showArray :: Show a => Show (Array a) where
instance showProxy :: Show (Proxy a) where
show _ = "Proxy"

instance showRecord :: (RL.RowToList rs ls, ShowRecordFields ls rs) => Show (Record rs) where
instance showRecord ::
( Nub rs rs'
, Nub rs' rs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be asserted with Nub rs rs?

, RL.RowToList rs' ls
, ShowRecordFields ls rs
) => Show (Record rs) where
show record = case showRecordFields (Proxy :: Proxy ls) record of
[] -> "{}"
fields -> intercalate " " ["{", intercalate ", " fields, "}"]
Expand Down