Created
April 26, 2020 19:59
-
-
Save walseb/1e0a0ca98aaa9469ab5da04e24f482c2 to your computer and use it in GitHub Desktop.
VectorSpace implemented using linear
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
import FRP.Yampa | |
import Linear as L | |
instance (Eq a, Floating a) => VectorSpace (V1 a) a where | |
zeroVector = L.zero | |
(*^) = (L.*^) | |
(^/) = (L.^/) | |
negateVector = L.negated | |
(^+^) = (L.^+^) | |
(^-^) = (L.^-^) | |
dot = L.dot | |
instance (Eq a, Floating a) => VectorSpace (V2 a) a where | |
zeroVector = L.zero | |
(*^) = (L.*^) | |
(^/) = (L.^/) | |
negateVector = L.negated | |
(^+^) = (L.^+^) | |
(^-^) = (L.^-^) | |
dot = L.dot | |
-- You could keep going with V3, V4, etc but you get the idea |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment