Skip to content

Instantly share code, notes, and snippets.

@apriori
Created April 24, 2016 17:24
Show Gist options
  • Save apriori/50f78152b89c3c2d50d11e098c354995 to your computer and use it in GitHub Desktop.
Save apriori/50f78152b89c3c2d50d11e098c354995 to your computer and use it in GitHub Desktop.
-- src/Scene/Object.hs:119:23:
-- Overlapping instances for Num (Exp Position)
-- arising from a use of ‘-’
-- Matching instances:
-- instance (Elt t, IsNum t) => Num (Exp t)
-- -- Defined in ‘accelerate-2.0.0.0:Data.Array.Accelerate.Language’
-- instance (Elt a, IsNum a) => Num (Exp (XYZ a)) -- Defined in ‘Vec3’
-- In the first argument of ‘normalise’, namely
-- ‘((point - spherePos sphere) :: Exp Position)’
-- In the expression:
-- normalise ((point - spherePos sphere) :: Exp Position)
-- In an equation for ‘sphereNormal’:
-- sphereNormal sphere point
--Vec instance
instance (Elt a, IsNum a) => Num (Exp (XYZ a)) where
(+) = lift2 ((+) :: XYZ (Exp a) -> XYZ (Exp a) -> XYZ (Exp a))
(-) = lift2 ((-) :: XYZ (Exp a) -> XYZ (Exp a) -> XYZ (Exp a))
(*) = lift2 ((*) :: XYZ (Exp a) -> XYZ (Exp a) -> XYZ (Exp a))
-- | Compute the surface normal of a sphere at a point
--
sphereNormal
:: Exp Sphere
-> Exp Position -- ^ A point on the surface of the sphere
-> Exp Direction -- ^ Normal at that point
sphereNormal sphere point
= normalise ((point - spherePos sphere) :: Exp Position)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment