spl / dlist

Difference lists in Haskell
https://hackage.haskell.org/package/dlist
BSD 3-Clause "New" or "Revised" License
65 stars 15 forks source link

Fix DNonEmpty show instance #95

Closed 414owen closed 3 years ago

414owen commented 3 years ago

Previous behaviour

λ> show $ fromNonEmpty [1, 2, 3]
"fromNonEmpty 1 :| [2,3]"
λ> read @(DNonEmpty Int) $ show $ fromNonEmpty [1, 2, 3]
fromNonEmpty *** Exception: Prelude.read: no parse

New behaviour

λ> show (fromNonEmpty [1, 2, 3 :: Int])
"fromNonEmpty (1 :| [2,3])"
λ> read @(DNonEmpty Int) $ show $ fromNonEmpty [1, 2, 3]
fromNonEmpty (1 :| [2,3])

Full disclosure: this change is ported directly from dlist-nonempty.

spl commented 3 years ago

Thanks for that! Would you mind adding a test for that case?