<div dir="ltr">Hi Claus,<br><br><div class="gmail_quote">On Wed, Jul 2, 2008 at 12:11 PM, Claus Reinke <span dir="ltr">&lt;<a href="mailto:claus.reinke@talk21.com">claus.reinke@talk21.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
ps. gmap itself is somewhat tricky to use, depending on<br>
 &nbsp; type information from the context, and failing with  &nbsp; runtime errors if that type information doesn&#39;t match.<br>
<br>
 &nbsp; *GMap&gt; gmap not (True,True) :: (Bool,Char)<br>
 &nbsp; (False,*** Exception: gunfold<br>
<br>
 &nbsp; But then, SYB generally operates at the borders<br>
 &nbsp; of type safety (what one would expect to be a<br>
 &nbsp; type error often just leads to unexpected behaviour<br>
 &nbsp; - there are so few gaps between well-typed SYB<br>
 &nbsp; programs that the type system, instead of noting<br>
 &nbsp; that things go wrong, can only cause things to go<br>
 &nbsp; elsewhere).<br>
<br>
 &nbsp; Are the other generic programming libraries better<br>
 &nbsp; behaved in this area?</blockquote><div><br>A small (and late) reaction to this point. The reason that this particular SYB gmap behaves badly is that deserialization is partial.<br><br>You will have a runtime error (or exceptional return value) if you deserialize an input as a value of type X while it has been serialized as a value of type Y. Since this version of gmap is based on serialization followed by deserialization, you will obtain such errors when demanding incompatible types (as in your example). I think that Oleg&#39;s latest version enforces additional type safety (by means of the gmap2 wrapper) so this problem is no longer present.<br>
<br>Other libraries (for example EMGM and RepLib) represent type constructors explicitly, so gmap can be implemented directly without the need of serialization/deserialization. There are no such runtime problems in those approaches.<br>
<br>There are other examples of serialization-based generic functions: the implementation of generic transpose by Norell and Jansson [1], and also the generic conversion work by Atanassow and Jeuring[2].<br><br>Cheers,<br>
<br>Alexey<br><br>[1] <a href="http://citeseer.ist.psu.edu/649955.html">http://citeseer.ist.psu.edu/649955.html</a><br>[2] <a href="http://citeseer.ist.psu.edu/583900.html">http://citeseer.ist.psu.edu/583900.html</a><br></div>
</div></div>