Hello<div><br></div><div>First of all I&#39;d like to say that I like vector-space and vector-space-opengl is something that I&#39;d like to use together with OpenGL.</div><div>So while using that library I found some things that can be useful for others, I think.</div>
<div><br></div><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>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><div><br></div><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><div><br></div><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>
<div><br></div><div>Thank you</div>