Hi Nikolay,<div><br></div><div>I am glad you found my work helpful, and thank you for the suggestions! Please find my responses interspersed below.</div><div><br></div><div><div class="gmail_quote">On Sun, May 20, 2012 at 5:59 AM, Nikolay Orlyuk <span dir="ltr">&lt;<a href="mailto:virkony@gmail.com" target="_blank">virkony@gmail.com</a>&gt;</span> wrote:</div>
<div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>While looking into OpenGL/TH.hs I found that it quite incomplete and I understand why. That suggestion at stackoverflow results in a bit boilerplate code:</div>
<div><blockquote>deriveScalar, deriveScalarAdditiveGroup, deriveScalarVectorSpace, deriveScalarAffineSpace :: [Name] -&gt; Q [Dec]<br>
deriveScalar ts = concat &lt;$&gt; forM decls (\qf -&gt; qf ts)<br>    where decls = [ deriveScalarAdditiveGroup<br>                  , deriveScalarVectorSpace<br>                  , deriveScalarAffineSpace<br>                  , deriveScalarInnerSpace<br>

                  ]<br>deriveScalarVectorSpace ts = concat &lt;$&gt; mapM f ts where<br>    f tn = do<br>        t &lt;- [t| $(conT tn) |]<br>        vs &lt;- [t| VectorSpace |]<br>        (AppT (ConT s) _) &lt;- [t| Scalar () |] -- dummy type to extract Scalar name<br>

        (VarE h) &lt;- [e| (*^) |] -- refer to actual (*^) from VectorSpace<br>        e &lt;- [e| (*) |] -- (*) from Num<br>        return [<br>            InstanceD [] (AppT vs t) [<br>                TySynInstD s [t] t,<br>

                ValD (VarP h) (NormalB e) []<br>            ]]</blockquote></div><div><div></div></div></blockquote><div>I&#39;ve not had an opportunity to work this since I finished the graphics course that motivated its creation, but would be happy to take your modifications as a github pull request (<a href="https://github.com/acfoltzer/vector-space-opengl">https://github.com/acfoltzer/vector-space-opengl</a>). I just couldn&#39;t justify the time getting the TH to work fully when I was chasing a deadline on a semester project.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>It&#39;s kinda partially checked and partially constructed. BTW, rather than depending on OpenGL its better to use Graphics.Rendering.OpenGL.Raw I think. Also there is types GLclampd and GLclampf (I suspect that they somehow related with OpenCL).</div>
</div></blockquote><div> </div><div><div>Regarding the dependency on OpenGL vs. OpenGLRaw, some of the semantic versions of the Data.Tensor types (Normal*, Color*) are defined in the full OpenGL package, so I will keep the dependency because of that.</div>
</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>While scalar types doesn&#39;t differ whether they are absolute whether they are not. Data.Tensor makes difference between Vertex and Vector. I suspect that made especially for this case: instance AffineSpace a =&gt; AffineSpace (Vertex2 a) where type Diff (Vertex2 a) = Vector2 (Diff a)</div>

<div>I.e. Diff Vertex shouldn&#39;t be Vertex and Vertex a should not belong to AdditiveGroup</div></blockquote><div><br></div><div>Regarding whether vertices and vectors should be treated uniformly, I particularly would appreciate corrections here. The original file was made by Emacs keyboard macro when the more sophisticated bits of Template Haskell failed to be straightforward, so I&#39;m sure there&#39;s plenty that one could do to improve the correctness vs. nearly-blind copypasta :)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>If anyone knows how to walk through the whole module in monad Q that might bring more power to this library. I.e. walk through OpenGL.Raw and make declarations  for all its scalar types.</div>
</blockquote><div><br></div><div>This, or use of GeneralizedNewtypeDeriving + StandAloneDeriving would be great to see.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>Thank you</div>
</blockquote></div><br></div><div>Thank you too!</div><div><br></div><div><div>Cheers,</div><div>Adam<br></div></div>