<br><div class="gmail_quote">On Thu, Dec 11, 2008 at 09:57, Neil Mitchell <span dir="ltr">&lt;<a href="mailto:ndmitchell@gmail.com">ndmitchell@gmail.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;">
HI Pedro,<br>
<div><div></div><div class="Wj3C7c"><br>
&gt; Would this help?<br>
&gt;<br>
&gt;&gt; {-# LANGUAGE ScopedTypeVariables &nbsp;#-}<br>
&gt;&gt; {-# LANGUAGE FlexibleContexts &nbsp; &nbsp; #-}<br>
&gt;&gt;<br>
&gt;&gt; module Data.Generics.Builders (empty) where<br>
&gt;&gt;<br>
&gt;&gt; import Data.Data<br>
&gt;&gt; import Data.Generics.Aliases (extB)<br>
&gt;&gt;<br>
&gt;&gt; -- | Construct the empty value for a datatype. For algebraic datatypes,<br>
&gt;&gt; the<br>
&gt;&gt; -- leftmost constructor is chosen.<br>
&gt;&gt; empty :: forall a. Data a =&gt; a<br>
&gt;&gt; empty = general<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; `extB` char<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; `extB` int<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; `extB` integer<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; `extB` float<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; `extB` double where<br>
&gt;&gt; &nbsp; -- Generic case<br>
&gt;&gt; &nbsp; general :: Data a =&gt; a<br>
&gt;&gt; &nbsp; general = fromConstrB empty (indexConstr (dataTypeOf general) 1)<br>
&gt;&gt;<br>
&gt;&gt; &nbsp; -- Base cases<br>
&gt;&gt; &nbsp; char &nbsp; &nbsp;= &#39;\NUL&#39;<br>
&gt;&gt; &nbsp; int &nbsp; &nbsp; = 0 &nbsp; &nbsp; &nbsp;:: Int<br>
&gt;&gt; &nbsp; integer = 0 &nbsp; &nbsp; &nbsp;:: Integer<br>
&gt;&gt; &nbsp; float &nbsp; = 0.0 &nbsp; &nbsp;:: Float<br>
&gt;&gt; &nbsp; double &nbsp;= 0.0 &nbsp; &nbsp;:: Double<br>
<br>
</div></div>Yep, that should do it!</blockquote><div><br>It&#39;s slated for release with the next version of the SYB library, so in a near future you&#39;ll only need to import it.<br>
<br>
<br>
Cheers,<br>
Pedro</div></div><br>