<div dir="ltr">Hi Richard,<div><br></div><div>Thanks for pointing me to the ticket; I agree that's the issue (although I'm glad to have you and Simon confirm it).  I've summarized the issue and raised the priority, and Simon linked to this thread.</div>
<div><br></div><div>I would have expected this would have affected a lot users, but as I haven't heard many complaints (and nobody else said anything here!) maybe the impact is smaller than I thought.</div><div><br></div>
<div>Thanks,</div><div>John</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 14, 2014 at 6:02 AM, Richard Eisenberg <span dir="ltr"><<a href="mailto:eir@cis.upenn.edu" target="_blank">eir@cis.upenn.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Is this an instance of <a href="https://ghc.haskell.org/trac/ghc/ticket/8177" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/8177</a> ? I think so.</div>
<div><br></div><div>The problem boils down to the fact that Vector and MVector are data families and are thus (currently) exempted from the roles mechanism. (Or, more properly, may *only* have nominal roles.) There is no technical reason for this restriction. It's just that the feature would take a few solid days of work to implement and I wasn't aware of a concrete use case.</div>
<div><br></div><div>Here is such a use case.</div><div><br></div><div>If you agree that you've hit #8177, please post to that bug report and raise the priority to High -- being able to coerce Vectors seems very reasonable indeed, and we should support it. I doubt the feature will land in 7.8.3 (depending on the timeline for that release), but I'll get to it eventually. (Or, if you feel this is more critical in the larger picture, shout more loudly on the ticket and perhaps I can squeeze it in before 7.8.3.)</div>
<div><br></div><div>Thanks,</div><div>Richard</div><br><div><div><div class="h5"><div>On May 13, 2014, at 9:39 PM, John Lato <<a href="mailto:jwlato@gmail.com" target="_blank">jwlato@gmail.com</a>> wrote:</div><br></div>
</div><blockquote type="cite"><div><div class="h5"><div dir="ltr">Hello,<div><br></div><div>Prior to ghc-7.8, it was possible to do this:</div><div><br></div><div>> module M where</div><div>></div><div>> import qualified <span>Data.Vector.Generic.Base as G</span></div>

<div><span>> i</span><span>mport qualified Data.Vector.Generic.Mutable as M</span></div><div><span>> i</span><span>mport Data.Vector.Unboxed.Base -- provides MVector and Vector</span></div>
<div><span>></span></div><div><span>> n</span><span>ewtype Foo = Foo Int deriving (Eq, Show, Num,</span></div><div><span>>     </span><span>M.MVector MVector, G.Vector Vector, Unbox)</span></div>
<div><span><br></span></div><div><span>M.MVector is defined as</span></div><div><span><br></span></div><div><span>> class MVector v a where</span></div>
<div><span>>     basicLength :: v s a -> Int</span></div><div><font>etc.</font></div><div><font><br></font></div><div><font>With ghc-7.8 this no longer compiles due to an unsafe coercion, as MVector s Foo and MVector s Int have different types.  The error suggests trying -XStandaloneDeriving to manually specify the context, however I don't see any way that will help in this case.</font></div>

<div><font><br></font></div><div><font>For that matter, I don't see any way to fix this in the vector package either.  We might think to define</font></div><div><font><br>
</font></div><div><font>> type role M.MVector nominal representational</font></div><div><font><br></font></div><div><font>but that doesn't work as both parameters to M.MVector require a nominal role (and it's probably not what we really want anyway).  Furthermore Data.Vector.Unboxed.Base.MVector (which fills in at `v` in the instance) is a data family, so we're stuck at that point also.</font></div>

<div><font><br></font></div><div><font>So given this situation, is there any way to automatically derive Vector instances from newtypes?</font></div><div><font><br></font></div>
<div><font>tl;dr: I would really like to be able to do:</font></div><div><font><br></font></div><div><font>> coerce (someVector :: Vector Foo) :: Vector Int</font></div><div>
<font><br></font></div><div><font>am I correct that the current machinery isn't up to handling this?</font></div><div><font><br></font></div><div><font>Thanks,</font></div>
<div><font>John</font></div></div></div></div><div class="">
_______________________________________________<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>
</div></blockquote></div><br></div></blockquote></div><br></div>