Skip to content

Instantly share code, notes, and snippets.

@nickpascucci
Last active March 21, 2016 03:44
Show Gist options
  • Select an option

  • Save nickpascucci/f618941df7f29e02c097 to your computer and use it in GitHub Desktop.

Select an option

Save nickpascucci/f618941df7f29e02c097 to your computer and use it in GitHub Desktop.

Revisions

  1. nickpascucci revised this gist Mar 21, 2016. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion units-err.hs
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,16 @@
    -- 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))
    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))
  2. nickpascucci created this gist Mar 21, 2016.
    4 changes: 4 additions & 0 deletions units-err.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    -- 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))