[Haskell-cafe] Deriving Show for non-regular data types

Mark Laws mdl at 60hz.org
Wed Mar 11 05:45:32 UTC 2015


Hi,

As part of studying Okasaki's PFDS book, I wanted to add Show support
for each of the data structures, and some have proven to be challenging,
as some of the types are non-regular and automatic derivation of Show
doesn't work.  I've been able to add some code that introduces a
supplementary type class that serves as a way to pass "proof" that the
wrapping data type supports traversal for Show-ability, but the solution
seems unsatisfactory.  I would greatly appreciate any suggestions for
improvements.  I've attached the code; the relevant bits are in
BankersDeque.hs, Example.hs, NestedShowable.hs, and
SimpleCatenableDeque.hs.  The same code is available here:

https://gist.github.com/drvink/30fb2a2b257fc99af281

Thanks,
Mark Laws

-- 
|v\ /\ |\ |< |_ /\ \^| //
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pfds-haskell.tar.gz
Type: application/x-gzip
Size: 2288 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150311/0ec28a32/attachment.bin>


More information about the Haskell-Cafe mailing list