-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Tensor and Group typeclasses -- -- Typeclasses for Groups (Monoids with an invert operation) and -- Tensors. @package data-tensor @version 0.1.0.0 -- | Typeclasses for Group and Tensor, extending Monoid. module Data.Tensor -- | A group is a monoid with an invert operation. Intuition: -- >< is to <> what subtraction is to addition; -- invert turns a value into its complement (see Laws below), and -- corresponds with unary minus in addition. -- -- Laws: -- --
-- a >< b == a <> (invert b) -- a >< mempty == a -- a >< a == mempty -- a <> (invert a) == mempty -- invert mempty == mempty --class Monoid a => Group a where a >< b = a <> invert b invert x = mempty >< x -- | Dual to <>. (><) :: Group a => a -> a -> a -- | "Negation": convert an operand into its dual. invert :: Group a => a -> a -- | Tensor allows us to define a relationship between two types, the -- second one forming a Group. The intuition is that the first type -- models something like a "location", and the second (the group) models -- the relative distance between two locations. Examples of Tensors -- include date/time values (point in time) and timespans; positions in a -- vector space and displacement vectors; pitches and intervals in music. -- -- Tensor provides three operations: ?<> ("tensor -- addition"), adding a "distance" to a "location"; ?>< -- ("tensor subtraction"), undoing the effect of adding a "distance" to a -- "location", and >?<, getting the "distance" between two -- "locations". -- -- Laws: -- --
-- a ?<> (b >?< a) == b -- a ?<> (x <> y) == a ?<> x ?<> y -- a ?>< b == a ?<> (invert b) -- a ?<> (x >< y) == a ?<> x ?>< y --class Group b => Tensor a b where a ?>< b = a ?<> invert b (?<>) :: Tensor a b => a -> b -> a (?><) :: Tensor a b => a -> b -> a (>?<) :: Tensor a b => a -> a -> b instance GHC.Num.Num a => Data.Tensor.Group (Data.Monoid.Sum a) instance Data.Tensor.Group a => Data.Tensor.Tensor a a