-- Behavior-level vector spaces

module VectorSpaceB where

import BaseTypes
import FRPImpl
import qualified VectorSpace as VS

infixr 7 *^, ^/, `dot`
infixl 6 ^+^, ^-^

zeroVector :: VS.VectorSpace v => Behavior v
zeroVector  = constantB VS.zeroVector

(*^) :: VS.VectorSpace v => Behavior Scalar
                  -> Behavior v -> Behavior v
(*^) = lift2 (VS.*^)

(^/) :: VS.VectorSpace v => Behavior v ->
           Behavior Scalar -> Behavior v
(^/) = lift2 (VS.^/)

(^+^),(^-^) :: VS.VectorSpace v => Behavior v
                  -> Behavior v -> Behavior v
(^+^) = lift2 (VS.^+^)
(^-^) = lift2 (VS.^-^)

dot :: VS.VectorSpace v => Behavior v
                  -> Behavior v -> Behavior Scalar
dot = lift2 VS.dot

magnitude, magnitudeSquared
   :: VS.VectorSpace v => Behavior v -> Behavior Scalar
magnitudeSquared = lift1 VS.magnitudeSquared
magnitude        = lift1 VS.magnitude

normalize :: VS.VectorSpace v => Behavior v -> Behavior v
normalize = lift1 VS.normalize

lerpVS :: VS.VectorSpace v => Behavior v -> Behavior v -> Behavior Scalar
       -> Behavior v
lerpVS = lift3 VS.lerpVS

-- Variant in which the first two arguments are constant.
lerpVS' :: VS.VectorSpace v => v -> v -> Behavior Scalar -> Behavior v
lerpVS' x0 x1 = lift1 (VS.lerpVS x0 x1)
