Hi,<br><div class="gmail_quote"><br>I&#39;ve been playing with generics in general (pardon the pun) and Uniplate in particular, and found out that strict data fields somehow derail Uniplate.<br><br>Observe:<br>=== code ===<br>

<div>
<pre><span><span>{-# LANGUAGE DeriveDataTypeable #-}</span><br></span><span><span>module</span> <span>Test</span> <span>where</span><br></span><span><br>
</span><span><span>import</span> <span>Data.Generics</span> <span>(</span><span>Data</span><span>(</span><span>..</span><span>),</span><span>Typeable</span><span>(</span><span>..</span><span>))</span><br>
</span><span><span>import</span> <span>Data.Generics.PlateData</span><br></span><span><span>import</span> <span>Data.ByteString</span><br></span><span><span>import</span> <span>Data.ByteString.Char8</span> <span>as</span> <span>C</span><br>


</span><span><br></span><span><span>data</span> <span>Foo</span> <span>=</span> <span>Foo</span> <span>String</span> <span>deriving</span> <span>(</span><span>Show</span><span>,</span> <span>Data</span><span>,</span> <span>Typeable</span><span>)</span><br>


</span><span><span>tst1</span> <span>=</span> <span>[</span> <span>Foo</span> <span>&quot;a&quot;</span><span>,</span> <span>Foo</span> <span>&quot;b&quot;</span> <span>]</span><br>
</span><span><span>test1</span> <span>=</span> <span>[</span> <span>show</span> <span>x</span> <span>|</span> <span>Foo</span> <span>x</span> <span>&lt;-</span> <span>universeBi</span> <span>tst1</span> <span>]</span><br>


</span><span><br></span><span><span>-- *Test&gt; test1</span><br></span><span><span>-- [&quot;\&quot;a\&quot;&quot;,&quot;\&quot;b\&quot;&quot;]</span><br>
</span><span><br></span><span><br></span><span><span>data</span> <span>Bar</span> <span>=</span> <span>Bar</span> <span>ByteString</span> <span>deriving</span> <span>(</span><span>Show</span><span>,</span> <span>Data</span><span>,</span> <span>Typeable</span><span>)</span><br>


</span><span><span>tst2</span> <span>=</span> <span>[</span> <span>Bar</span> <span>(</span><span>C</span><span>.</span><span>pack</span> <span>&quot;a&quot;</span><span>),</span> <span>Bar</span> <span>(</span><span>C</span><span>.</span><span>pack</span> <span>&quot;b&quot;</span><span>)</span> <span>]</span><br>


</span><span><span>test2</span> <span>=</span> <span>[</span> <span>show</span> <span>x</span> <span>|</span> <span>Bar</span> <span>x</span> <span>&lt;-</span> <span>universeBi</span> <span>tst2</span> <span>]</span><br>


</span><span><br></span><span><span>-- *Test&gt; test2</span><br></span><span><span>-- *** Exception: Prelude.undefined</span><br></span>=== end of code ===<span><br>
<br></span><span></span></pre></div>First, I thought that instance of Data for ByteString is somehow deficient, but this is not the case.<br><br>If you change definition of Foo to &quot;data Foo = Foo !String&quot;, you would get the same error with &quot;Prelude.undefined&quot;.<br>


<br>Since all fields in ByteString constructors are strict, I have no joy trying to use it with Uniplate.<br><br>Howere, my type-foo is not strong enough to understand what&#39;s wrong. Could someone give me a hint?<br><br>


PS<br>ghc 6.10.4<br>uniplate 1.2.0.3<br>bytestring 0.9.1.4<br clear="all"><br>PPS<br>Neil Mitchell is receiving a copy of this email<br></div><br>-- <br>Dmitry Astapov<br>