The missing dataCast1 is just a bug, yes. I suppose someone who uses Bag and cares can submit something about fixing gunfold.<br><br><div class="gmail_quote">On Thu, Sep 20, 2012 at 7:22 AM, José Pedro Magalhães <span dir="ltr">&lt;<a href="mailto:jpm@cs.uu.nl" target="_blank">jpm@cs.uu.nl</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Right now I was just planning to fix the missing dataCast1 from Bag, and the rest from<br>Data.Data (see <a href="http://hackage.haskell.org/trac/ghc/ticket/7256" target="_blank">http://hackage.haskell.org/trac/ghc/ticket/7256</a>). I think those are just<br>


a bug, unrelated to the abstraction story, no?<br><br><br>Cheers,<br>Pedro<div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">On Thu, Sep 20, 2012 at 12:19 PM, Edward Kmett <span dir="ltr">&lt;<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Note: It was probably built with an eye towards how Data.Map and the like performed abstraction. However, This isn&#39;t necessary to protect the invariants of a bag. <div>


<br></div><div>The constructors exposed via Data do not have to be the actual constructors of the data type. With this you can quotient out the portions of the structure you don&#39;t want the user to be able to inspect.<div>



<br></div><div>See the libraries@ proposal that I put in 3-4 weeks ago (which will have just passed) to fix all the broken Data instances for containers by using virtual constructors such as &#39;fromList&#39;, (which incidentally led to Milan finding huge space and time improvements in fromList).<div>



<br></div><div>Effectively allowing the user to use the &#39;listToBag&#39; as a &quot;constructor&quot; loses no information violates no invariants, and prevents code written for uniplate, SYB, etc. from having to crash, panic or give up upon the sight of a mkNoRepType.</div>



<div><br></div><div>My reaction for years to the sight of a mkNoRepType and undefined gunfold has been to hang my head. Now I just fix them.</div><span><font color="#888888"><div><br></div><div>-Edward</div>

</font></span><div><br><div class="gmail_quote"><div>On Wed, Aug 29, 2012 at 7:11 AM, José Pedro Magalhães <span dir="ltr">&lt;<a href="mailto:jpm@cs.uu.nl" target="_blank">jpm@cs.uu.nl</a>&gt;</span> wrote:<br>


</div><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Philip,<br><br><div class="gmail_quote"><div>On Wed, Aug 29, 2012 at 12:01 PM, Philip Holzenspies <span dir="ltr">&lt;<a href="mailto:pkfh@st-andrews.ac.uk" target="_blank">pkfh@st-andrews.ac.uk</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Dear GHCers,<br>
<br>
I&#39;m performing traversals over GHC-API results (HsSyn et al). For this purpose, I&#39;m using SYB generics.<br>
<br>
I found that I couldn&#39;t use &quot;ext1Q&quot; for a function with type &quot;Data x =&gt; Bag x -&gt; String&quot;, i.e. that this function was never applied. The source of Bag&#39;s instance of the Data class seems to explain why:<br>






<br>
<br>
instance Data a =&gt; Data (Bag a) where<br>
  gfoldl k z b = z listToBag `k` bagToList b -- traverse abstract type abstractly<br>
  toConstr _   = abstractConstr $ &quot;Bag(&quot;++show (typeOf (undefined::a))++&quot;)&quot;<br>
  gunfold _ _  = error &quot;gunfold&quot;<br>
  dataTypeOf _ = mkNoRepType &quot;Bag&quot;<br>
<br>
<br>
Is there a rationale to not allow gunfolds and to keep toConstr abstract?</blockquote></div><div><br>As far as I understand, this is to keep `Bag` itself abstract, preventing users from inspecting its internals.<br> </div>



<div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

 More to the point for my needs, is there a reason to not allow dataCast1 casting of Bags?<br></blockquote></div><div><br>That is a separate issue; I believe this instance is just missing a `dataCast1 = gcast1` line.<br>



All datatypes of kind `* -&gt; *` should have such a definition.<br>

<br>(Having a look at Data.Data, I guess the same applies to `Ptr a` and `ForeignPtr a`.<br>And `Array a b` seems to be missing the `dataCast2` method. I propose fixing all of these.)<br><br><br>Cheers,<br>Pedro<br> </div>



<div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Regards,<br>
Philip<br>
_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org" target="_blank">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
</blockquote></div></div><br>
<br>_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org" target="_blank">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
<br></blockquote></div></div></div><br></div></div></div>
</blockquote></div><br>
</div></div></blockquote></div><br>