Hello<div><br></div><div>First of all I'd like to say that I like vector-space and vector-space-opengl is something that I'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] -> Q [Dec]<br>
deriveScalar ts = concat <$> forM decls (\qf -> qf ts)<br> where decls = [ deriveScalarAdditiveGroup<br> , deriveScalarVectorSpace<br> , deriveScalarAffineSpace<br> , deriveScalarInnerSpace<br>
]<br>deriveScalarVectorSpace ts = concat <$> mapM f ts where<br> f tn = do<br> t <- [t| $(conT tn) |]<br> vs <- [t| VectorSpace |]<br> (AppT (ConT s) _) <- [t| Scalar () |] -- dummy type to extract Scalar name<br>
(VarE h) <- [e| (*^) |] -- refer to actual (*^) from VectorSpace<br> e <- [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'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'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 => AffineSpace (Vertex2 a) where type Diff (Vertex2 a) = Vector2 (Diff a)</div>
<div>I.e. Diff Vertex shouldn'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>