The biggest problem with the RULES based approach is that if you are in a context where the RULES don&#39;t or can&#39;t fire, then your semantics silently change. This leads to subtle bugs which only show up in ghci, etc.<br>
<br>On Friday, October 28, 2011, Jason Dagit &lt;<a href="mailto:dagitj@gmail.com">dagitj@gmail.com</a>&gt; wrote:<br>&gt; On Fri, Oct 28, 2011 at 2:07 PM, Edward Kmett &lt;<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>&gt; wrote:<br>
&gt;&gt; Jason,<br>&gt;&gt; Thank you for taking ownership of HOpenGL!<br>&gt;<br>&gt; Thanks!<br>&gt;<br>&gt;&gt; I would like to make a formal request for there to be some way to get access<br>&gt;&gt; to either<br>&gt;&gt; Graphics.Rendering.OpenGL.Raw.Core31.TypesInternal<br>
&gt;&gt; or that<br>&gt;&gt; Graphics.Rendering.OpenGL.Raw.Core31.Types<br>&gt;&gt; re-export the newtype wrappers it places around CDouble and CFloat.<br>&gt;&gt; As things stand the only way to work with them is to pointlessly round-trip<br>
&gt;&gt; through rational or pray that GHC is smart enough to automatically convert<br>&gt;&gt; once it sees through the newtype, which it isn&#39;t, potentially costing me<br>&gt;&gt; orders of magnitude of performance in tight loops in exchange for<br>
&gt;&gt; implementation freedom the current OpenGL bindings do not use on any<br>&gt;&gt; platform.<br>&gt;<br>&gt; Yes, it&#39;s a real problem.  I think there are a couple directions we<br>&gt; could move in (and some may not even be mutually exclusive).<br>
&gt;<br>&gt; Andy Gill created this workaround:<br>&gt; {-# RULES &quot;realToFrac/a-&gt;GLfloat&quot; realToFrac = \x -&gt; GLfloat (realToFrac x)<br>&gt; #-}<br>&gt; {-# RULES &quot;realToFrac/GLfloat-&gt;a&quot; realToFrac = \(GLfloat x) -&gt; realToFrac x<br>
&gt; #-}<br>&gt;<br>&gt; That one helps a lot for most people.<br>&gt;<br>&gt; Someone made a libraries proposal that also helps the conversion<br>&gt; situation but I don&#39;t have the details handy at the moment.<br>&gt;<br>
&gt; If you read here, I&#39;d like to get some MArray support in and I think<br>&gt; it&#39;s possible, although I haven&#39;t the idea I proposed yet:<br>&gt; <a href="http://www.haskell.org/pipermail/haskell-cafe/2011-March/090511.html">http://www.haskell.org/pipermail/haskell-cafe/2011-March/090511.html</a><br>
&gt;<br>&gt; Another thing we could do is find a different balance between newtypes<br>&gt; and the C types.<br>&gt;<br>&gt; I&#39;m totally onboard with exposing all of OpenGLRaw.  I think we just<br>&gt; need to sufficiently document the &quot;internal&quot; bits so that only people<br>
&gt; who absolutely need them will use them.  That&#39;s how I see ByteString<br>&gt; and it seems to be working there.<br>&gt;<br>&gt; Thanks for your suggestion (and your pull request on github, yay for<br>&gt; collaborative tools!).<br>
&gt;<br>&gt; Jason<br>&gt;