<p dir="ltr">You may want to look at the Show1 class, which may or may not help you any. You also may or may not find Ralf Hinze's paper "Numerical Representations as Higher-Order Nested Datatypes" helpful. Nested types can be extremely efficient in certain situations, and it's not *usually* too terribly hard to read code that uses them, but writing it is an entirely different story. In some cases, you can get good results using GADTs to enforce your shape invariants, and they tend to be a lot easier to work with.</p>
<div class="gmail_quote">On Mar 11, 2015 1:45 AM, "Mark Laws" <<a href="mailto:mdl@60hz.org">mdl@60hz.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
As part of studying Okasaki's PFDS book, I wanted to add Show support<br>
for each of the data structures, and some have proven to be challenging,<br>
as some of the types are non-regular and automatic derivation of Show<br>
doesn't work.  I've been able to add some code that introduces a<br>
supplementary type class that serves as a way to pass "proof" that the<br>
wrapping data type supports traversal for Show-ability, but the solution<br>
seems unsatisfactory.  I would greatly appreciate any suggestions for<br>
improvements.  I've attached the code; the relevant bits are in<br>
BankersDeque.hs, Example.hs, NestedShowable.hs, and<br>
SimpleCatenableDeque.hs.  The same code is available here:<br>
<br>
<a href="https://gist.github.com/drvink/30fb2a2b257fc99af281" target="_blank">https://gist.github.com/drvink/30fb2a2b257fc99af281</a><br>
<br>
Thanks,<br>
Mark Laws<br>
<br>
--<br>
|v\ /\ |\ |< |_ /\ \^| //<br>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div>