packages feed

linear 1.9.1 → 1.10

raw patch · 9 files changed

+56/−3 lines, 9 files

Files

CHANGELOG.markdown view
@@ -1,3 +1,7 @@+1.10+----+* Added `Hashable` instances+ 1.9.1 ----- * Added a role annotation to `V n a` to prevent users from using GHC 7.8's `Coercible` machinery to violate invariants.
linear.cabal view
@@ -1,6 +1,6 @@ name:          linear category:      Math, Algebra-version:       1.9.1+version:       1.10 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE
src/Linear/Plucker.hs view
@@ -53,6 +53,7 @@ import Data.Foldable as Foldable import Data.Functor.Bind import Data.Functor.Rep+import Data.Hashable import Data.Semigroup import Data.Semigroup.Foldable import Foreign.Ptr (castPtr)@@ -218,6 +219,10 @@   {-# INLINE (/) #-}   fromRational = pure . fromRational   {-# INLINE fromRational #-}++instance Hashable a => Hashable (Plucker a) where+  hashWithSalt s (Plucker a b c d e f) = s `hashWithSalt` a `hashWithSalt` b `hashWithSalt` c `hashWithSalt` d `hashWithSalt` e `hashWithSalt` f+  {-# INLINE hashWithSalt #-}  instance Storable a => Storable (Plucker a) where   sizeOf _ = 6 * sizeOf (undefined::a)
src/Linear/Quaternion.hs view
@@ -49,6 +49,7 @@ import Data.Foldable import Data.Functor.Bind import Data.Functor.Rep+import Data.Hashable import GHC.Arr (Ix(..)) import qualified Data.Foldable as F import Data.Monoid@@ -227,6 +228,10 @@       ij = isInfinite j       ik = isInfinite k   {-# INLINE signum #-}++instance Hashable a => Hashable (Quaternion a) where+  hashWithSalt s (Quaternion a b) = s `hashWithSalt` a `hashWithSalt` b+  {-# INLINE hashWithSalt #-}  qNaN :: RealFloat a => Quaternion a qNaN = Quaternion fNaN (V3 fNaN fNaN fNaN) where fNaN = 0/0
src/Linear/V0.hs view
@@ -1,13 +1,17 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE CPP #-} #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE Trustworthy #-} #endif++#ifndef MIN_VERSION_hashable+#define MIN_VERSION_hashable+#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2012-2013 Edward Kmett@@ -32,6 +36,7 @@ import Data.Foldable import Data.Functor.Rep import Data.Functor.Bind+import Data.Hashable import Data.Ix import Data.Semigroup import Foreign.Storable (Storable(..))@@ -142,6 +147,14 @@ instance Distributive V0 where   distribute _ = V0   {-# INLINE distribute #-}++instance Hashable (V0 a) where+#if (MIN_VERSION_hashable(1,2,1)) || !(MIN_VERSION_hashable(1,2,0))+  hash V0 = 0+  {-# INLINE hash #-}+#endif+  hashWithSalt s V0 = s+  {-# INLINE hashWithSalt #-}  instance Epsilon a => Epsilon (V0 a) where   nearZero _ = True
src/Linear/V1.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveFoldable #-}@@ -8,11 +9,14 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ScopedTypeVariables #-} -- {-# OPTIONS_GHC -fno-warn-name-shadowing #-}-{-# LANGUAGE CPP #-} #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DeriveGeneric #-} #endif++#ifndef MIN_VERSION_hashable+#define MIN_VERSION_hashable(x,y,z) 1+#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2012-2013 Edward Kmett,@@ -40,6 +44,7 @@ import Data.Foldable import Data.Functor.Bind import Data.Functor.Rep+import Data.Hashable import Data.Semigroup.Foldable import Foreign.Storable (Storable) import GHC.Arr (Ix(..))@@ -152,6 +157,12 @@   {-# INLINE (/) #-}   fromRational = pure . fromRational   {-# INLINE fromRational #-}++instance Hashable a => Hashable (V1 a) where+#if (MIN_VERSION_hashable(1,2,1)) || !(MIN_VERSION_hashable(1,2,0))+  hash (V1 a) = hash a+#endif+  hashWithSalt s (V1 a) = s `hashWithSalt` a  instance Metric V1 where   dot (V1 a) (V1 b) = a * b
src/Linear/V2.hs view
@@ -36,6 +36,7 @@ import Data.Data import Data.Distributive import Data.Foldable+import Data.Hashable import Data.Functor.Bind import Data.Functor.Rep import Data.Semigroup@@ -115,6 +116,10 @@   {-# INLINE pure #-}   V2 a b <*> V2 d e = V2 (a d) (b e)   {-@ INLINE (<*>) #-}++instance Hashable a => Hashable (V2 a) where+  hashWithSalt s (V2 a b) = s `hashWithSalt` a `hashWithSalt` b+  {-# INLINE hashWithSalt #-}  instance Additive V2 where   zero = pure 0
src/Linear/V3.hs view
@@ -38,6 +38,7 @@ import Data.Foldable import Data.Functor.Bind import Data.Functor.Rep+import Data.Hashable import Data.Semigroup import Data.Semigroup.Foldable import Foreign.Ptr (castPtr)@@ -149,6 +150,10 @@   {-# INLINE (/) #-}   fromRational = pure . fromRational   {-# INLINE fromRational #-}++instance Hashable a => Hashable (V3 a) where+  hashWithSalt s (V3 a b c) = s `hashWithSalt` a `hashWithSalt` b `hashWithSalt` c+  {-# INLINE hashWithSalt #-}  instance Metric V3 where   dot (V3 a b c) (V3 d e f) = a * d + b * e + c * f
src/Linear/V4.hs view
@@ -39,6 +39,7 @@ import Data.Foldable import Data.Functor.Bind import Data.Functor.Rep+import Data.Hashable import Data.Semigroup import Data.Semigroup.Foldable import Foreign.Ptr (castPtr)@@ -163,6 +164,10 @@                     (fmap (\(V4 _ _ z _) -> z) f)                     (fmap (\(V4 _ _ _ w) -> w) f)   {-# INLINE distribute #-}++instance Hashable a => Hashable (V4 a) where+  hashWithSalt s (V4 a b c d) = s `hashWithSalt` a `hashWithSalt` b `hashWithSalt` c `hashWithSalt` d+  {-# INLINE hashWithSalt #-}  -- | A space that distinguishes orthogonal basis vectors '_x', '_y', '_z', '_w'. (It may have more.) class R3 t => R4 t where