Skip to content

Instantly share code, notes, and snippets.

@nickpascucci
Last active March 21, 2016 03:44
Show Gist options
  • Save nickpascucci/f618941df7f29e02c097 to your computer and use it in GitHub Desktop.
Save nickpascucci/f618941df7f29e02c097 to your computer and use it in GitHub Desktop.
-- Vector magnitude/absolute value. This doesn't type check - if you
-- can figure out why, please leave a comment!
magnitude :: Vec (Qu d l n) -> Qu d l n
magnitude (Vec3 x y z) = qSqrt ((qSq x) |+| (qSq y) |+| (qSq z))
-- Couldn't match type ‘d’ with ‘Normalize (d @@+ d) @/ Two’
-- ‘d’ is a rigid type variable bound by the type signature for interactive:IHaskell128.magnitude :: Vec (Qu d l n) -> Qu d l n at :1:14
-- Expected type: Qu d l n
-- Actual type: Qu (Normalize (d @@+ d) @/ Two) l n
-- Relevant bindings include
-- z :: Qu d l n (bound at :2:21)
-- y :: Qu d l n (bound at :2:19)
-- x :: Qu d l n (bound at :2:17)
-- magnitude :: Vec (Qu d l n) -> Qu d l n (bound at :2:1)
-- In the expression: qSqrt ((qSq x) |+| (qSq y) |+| (qSq z))
-- In an equation for ‘magnitude’: magnitude (Vec3 x y z) = qSqrt ((qSq x) |+| (qSq y) |+| (qSq z))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment