packages feed

linear 1.21.7 → 1.21.8

raw patch · 20 files changed

+88/−533 lines, 20 filesdep ~basedep ~distributivedep ~hashable

Dependency ranges changed: base, distributive, hashable, reflection, tagged, template-haskell, transformers, transformers-compat, vector

Files

CHANGELOG.markdown view
@@ -1,3 +1,8 @@+1.21.8 [2021.11.15]+-------------------+* Allow building with `hashable-1.4.*`.+* Drop support for pre-8.0 versions of GHC.+ 1.21.7 [2021.09.20] ------------------- * Fix a build error when using `random-1.2.1` or later.
linear.cabal view
@@ -1,6 +1,6 @@ name:          linear category:      Math, Algebra-version:       1.21.7+version:       1.21.8 license:       BSD3 cabal-version: >= 1.10 license-file:  LICENSE@@ -13,17 +13,14 @@ synopsis:      Linear Algebra description:   Types and combinators for linear algebra on free vector spaces build-type:    Simple-tested-with:   GHC == 7.4.2-             , GHC == 7.6.3-             , GHC == 7.8.4-             , GHC == 7.10.3-             , GHC == 8.0.2+tested-with:   GHC == 8.0.2              , GHC == 8.2.2              , GHC == 8.4.4              , GHC == 8.6.5              , GHC == 8.8.4-             , GHC == 8.10.4+             , GHC == 8.10.7              , GHC == 9.0.1+             , GHC == 9.2.1 extra-source-files:   .gitignore   .hlint.yaml@@ -51,31 +48,31 @@ library   build-depends:     adjunctions          >= 4     && < 5,-    base                 >= 4.5   && < 5,+    base                 >= 4.9   && < 5,     base-orphans         >= 0.8.3 && < 1,     binary               >= 0.5   && < 0.9,     bytes                >= 0.15  && < 1,     cereal               >= 0.4.1.1 && < 0.6,     containers           >= 0.4   && < 0.7,     deepseq              >= 1.1   && < 1.5,-    distributive         >= 0.2.2 && < 1,+    distributive         >= 0.5.1 && < 1,     ghc-prim,-    hashable             >= 1.1   && < 1.4,+    hashable             >= 1.2.7.0 && < 1.5,     indexed-traversable  >= 0.1.1 && < 0.2,     lens                 >= 4.15.2 && < 6,     random               >= 1.0   && < 1.3,-    reflection           >= 1.3.2 && < 3,+    reflection           >= 2     && < 3,     semigroups           >= 0.9   && < 1,     semigroupoids        >= 5.2.1 && < 6,-    tagged               >= 0.4.4 && < 1,-    transformers         >= 0.2   && < 0.6,-    transformers-compat  >= 0.4   && < 1,+    tagged               >= 0.8.6 && < 1,+    transformers         >= 0.5   && < 0.6,+    transformers-compat  >= 0.5.0.4 && < 1,     unordered-containers >= 0.2.3 && < 0.3,-    vector               >= 0.10  && < 0.13,+    vector               >= 0.12.1.2 && < 0.13,     void                 >= 0.6   && < 1    if flag(template-haskell) && impl(ghc)-    build-depends: template-haskell >= 2.7 && < 3.0+    build-depends: template-haskell >= 2.11.1.0 && < 3.0    if flag(herbie)     build-depends: HerbiePlugin >= 0.1 && < 0.2@@ -106,19 +103,9 @@     Linear.V4     Linear.Vector -  ghc-options: -Wall -fwarn-tabs -O2 -fdicts-cheap -funbox-strict-fields+  ghc-options: -Wall -Wtabs -O2 -fdicts-cheap -funbox-strict-fields -Wno-trustworthy-safe   hs-source-dirs: src -  if impl(ghc >= 7.10)-    ghc-options: -fno-warn-trustworthy-safe--  -- hack around the buggy unused matches check for class associated types in ghc 8 rc1-  if impl(ghc >= 8)-    ghc-options: -fno-warn-unused-matches--  if impl(ghc >= 8.6)-    ghc-options: -Wno-star-is-type-   default-language: Haskell2010    x-docspec-extra-packages: simple-reflect@@ -138,9 +125,7 @@ test-suite UnitTests   type:           exitcode-stdio-1.0   main-is:        UnitTests.hs-  other-modules:  Plucker, Binary-  if impl(ghc >= 7.7)-    other-modules: V+  other-modules:  Plucker, Binary, V   ghc-options:    -Wall -threaded   hs-source-dirs: tests   build-depends:
src/Linear/Affine.hs view
@@ -7,15 +7,11 @@ {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE RankNTypes #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DeriveGeneric #-}-#endif {-# LANGUAGE DeriveDataTypeable #-}-#if defined(__GLASGOW_HASKELL__) {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE ScopedTypeVariables #-}-#endif  #ifndef MIN_VERSION_hashable #define MIN_VERSION_hashable(x,y,z) 1@@ -38,9 +34,7 @@ import Control.Lens import Data.Binary as Binary import Data.Bytes.Serial-#if __GLASGOW_HASKELL__ >= 708 import Data.Coerce-#endif import Data.Complex (Complex) import Data.Data import Data.Distributive@@ -51,15 +45,11 @@ import Data.Functor.Rep as Rep import Data.HashMap.Lazy (HashMap) import Data.Hashable-#if (MIN_VERSION_hashable(1,2,5)) import Data.Hashable.Lifted-#endif import Data.IntMap (IntMap) import Data.Ix+import Data.Kind import Data.Map (Map)-#if !(MIN_VERSION_base(4,8,0))-import Data.Monoid (Monoid(..))-#endif #if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup (Semigroup) #endif@@ -69,12 +59,7 @@ import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed.Base as U import Foreign.Storable-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#endif-#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif+import GHC.Generics (Generic, Generic1) import Linear.Epsilon import Linear.Metric import Linear.Plucker@@ -95,7 +80,7 @@ -- > (a .+^ u) .+^ v  =  a .+^ (u ^+^ v)@ -- > (a .-. b) ^+^ v  =  (a .+^ v) .-. q@ class Additive (Diff p) => Affine p where-  type Diff p :: * -> *+  type Diff p :: Type -> Type    infixl 6 .-.   -- | Get the difference between two points as a vector offset.@@ -160,23 +145,13 @@            , Fractional , Num, Ix, Storable, Epsilon            , Semigroup, Monoid            , Random, Hashable-#if __GLASGOW_HASKELL__ >= 702-           , Generic-#endif-#if __GLASGOW_HASKELL__ >= 706-           , Generic1-#endif-#if __GLASGOW_HASKELL__ >= 708-           , Typeable, Data-#endif+           , Generic, Generic1, Data            ) -#if __GLASGOW_HASKELL__ >= 707 instance Finite f => Finite (Point f) where   type Size (Point f) = Size f   toV (P v) = toV v   fromV v = P (fromV v)-#endif  instance NFData (f a) => NFData (Point f a) where   rnf (P x) = rnf x@@ -197,20 +172,10 @@   put (P p) = Cereal.put p   get = P `liftM` Cereal.get -#if (MIN_VERSION_hashable(1,2,5)) instance Hashable1 f => Hashable1 (Point f) where   liftHashWithSalt h s (P f) = liftHashWithSalt h s f   {-# INLINE liftHashWithSalt #-}-#endif -#if __GLASGOW_HASKELL__ < 708-instance forall f. Typeable1 f => Typeable1 (Point f) where-  typeOf1 _ = mkTyConApp (mkTyCon3 "linear" "Linear.Affine" "Point") [] `mkAppTy`-              typeOf1 (undefined :: f a)--deriving instance (Data (f a), Typeable1 f, Typeable a) => Data (Point f a)-#endif- lensP :: Lens' (Point g a) (g a) lensP afb (P a) = P <$> afb a {-# INLINE lensP #-}@@ -225,7 +190,6 @@   _Wrapped' = _Point   {-# INLINE _Wrapped' #-} -#if __GLASGOW_HASKELL__ >= 708 -- These are stolen from Data.Profunctor.Unsafe (.#) :: Coercible b a => (b -> c) -> (a -> b) -> a -> c f .# _ = coerce f@@ -234,13 +198,6 @@ (#.) :: Coercible c b => (b -> c) -> (a -> b) -> a -> c (#.) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b {-# INLINE (#.) #-}-#else-(.#), (#.) :: (b -> c) -> (a -> b) -> a -> c-(.#) = (.)-{-# INLINE (.#) #-}-(#.) = (.)-{-# INLINE (#.) #-}-#endif  unP :: Point f a -> f a unP (P x) = x@@ -250,11 +207,7 @@ -- role troubles. However, GHC 7.8 and above let us use -- explicit coercions for (>>-). instance Bind f => Bind (Point f) where-#if __GLASGOW_HASKELL__ >= 708   (>>-) = ((P .) . (. (unP .))) #. (>>-) .# unP-#else-  P m >>- f = P $ m >>- unP . f-#endif   join (P m) = P $ m >>- \(P m') -> m'  instance Distributive f => Distributive (Point f) where@@ -337,10 +290,8 @@   basicUnsafeNew n = MV_P `liftM` M.basicUnsafeNew n   basicUnsafeRead (MV_P v) i = P `liftM` M.basicUnsafeRead v i   basicUnsafeWrite (MV_P v) i (P x) = M.basicUnsafeWrite v i x-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_P v) = M.basicInitialize v   {-# INLINE basicInitialize #-}-#endif  instance U.Unbox (f a) => G.Vector U.Vector (Point f a) where   {-# INLINE basicUnsafeFreeze #-}
src/Linear/Algebra.hs view
@@ -2,9 +2,6 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}-#if __GLASGOW_HASKELL__ >= 800-{-# OPTIONS_GHC -fno-warn-redundant-constraints #-} -- they are mathematically required, not redundant, damn it.-#endif ----------------------------------------------------------------------------- -- | -- License     :  BSD-style (see the file LICENSE)
src/Linear/Binary.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2013-2015 Edward Kmett and Anthony Cowley@@ -16,16 +15,8 @@   , getLinear   ) where -#if __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif import Data.Binary-#if __GLASGOW_HASKELL__ < 710-import Data.Foldable (Foldable, traverse_)-import Data.Traversable (Traversable, sequenceA)-#else import Data.Foldable (traverse_)-#endif  -- | Serialize a linear type. putLinear :: (Binary a, Foldable t) => t a -> Put
src/Linear/Conjugate.hs view
@@ -1,8 +1,5 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DefaultSignatures #-}-#if __GLASGOW_HASKELL__ >= 800-{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}-#endif  ----------------------------------------------------------------------------- -- |
src/Linear/Matrix.hs view
@@ -2,10 +2,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif+{-# LANGUAGE TypeFamilies #-}  --------------------------------------------------------------------------- -- |@@ -35,7 +33,6 @@   , _m22, _m23, _m24   , _m32, _m33, _m34   , _m42, _m43, _m44-#if MIN_VERSION_base(4,8,0)   , lu   , luFinite   , forwardSub@@ -48,18 +45,16 @@   , luInvFinite   , luDet   , luDetFinite-#endif   ) where -#if __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif import Control.Lens hiding (index) import Control.Lens.Internal.Context import Data.Distributive import Data.Foldable as Foldable import Data.Functor.Rep+import GHC.TypeLits import Linear.Quaternion+import Linear.V import Linear.V2 import Linear.V3 import Linear.V4@@ -67,11 +62,6 @@ import Linear.Conjugate import Linear.Trace -#if MIN_VERSION_base(4,8,0)-import GHC.TypeLits-import Linear.V-#endif- -- $setup -- >>> import Control.Lens hiding (index) -- >>> import Data.Complex (Complex (..))@@ -437,7 +427,6 @@                        (i20 * s3 - i21 * s1 + i22 * s0)) {-# INLINE inv44 #-} -#if MIN_VERSION_base(4,8,0) -- | Compute the (L, U) decomposition of a square matrix using Crout's --   algorithm. The 'Index' of the vectors must be 'Integral'. lu :: ( Num a@@ -724,7 +713,7 @@ luDet a =     let (l, u) = lu a         p      = Foldable.foldl (*) 1-    in (p (diagonal l)) * (p (diagonal u))+    in p (diagonal l) * p (diagonal u)  -- | Compute the determinant of a matrix using LU decomposition, using the --   vector's 'Finite' instance to provide an index.@@ -739,4 +728,3 @@             => m (m a)             -> a luDetFinite = luDet . fmap toV . toV-#endif
src/Linear/Metric.hs view
@@ -1,8 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DefaultSignatures #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2012-2015 Edward Kmett
src/Linear/Plucker.hs view
@@ -4,17 +4,10 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE GADTs #-}-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DeriveGeneric #-}-#endif-#if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE DataKinds #-}-#endif--#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE DeriveLift #-}-#endif  #ifndef MIN_VERSION_vector #define MIN_VERSION_vector(x,y,z) 1@@ -80,29 +73,20 @@ import Data.Semigroup.Foldable import Data.Serialize as Cereal import qualified Data.Traversable.WithIndex as WithIndex-#if __GLASGOW_HASKELL__ >= 707 import qualified Data.Vector as V-#endif import qualified Data.Vector.Generic.Mutable as M import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed.Base as U import Foreign.Ptr (castPtr) import Foreign.Storable (Storable(..)) import GHC.Arr (Ix(..))-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#endif-#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+import GHC.Generics (Generic, Generic1)+#if defined(MIN_VERSION_template_haskell) import Language.Haskell.TH.Syntax (Lift) #endif import Linear.Epsilon import Linear.Metric-#if __GLASGOW_HASKELL__ >= 707 import Linear.V-#endif import Linear.V2 import Linear.V3 import Linear.V4@@ -111,23 +95,16 @@  -- | Plücker coordinates for lines in a 3-dimensional space. data Plucker a = Plucker !a !a !a !a !a !a deriving (Eq,Ord,Show,Read-#if __GLASGOW_HASKELL__ >= 702-                                                    ,Generic-#endif-#if __GLASGOW_HASKELL__ >= 706-                                                    ,Generic1-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+                                                    ,Generic,Generic1+#if defined(MIN_VERSION_template_haskell)                                                     ,Lift #endif                                                     ) -#if __GLASGOW_HASKELL__ >= 707 instance Finite Plucker where   type Size Plucker = 6   toV (Plucker a b c d e f) = V (V.fromListN 6 [a,b,c,d,e,f])   fromV (V v) = Plucker (v V.! 0) (v V.! 1) (v V.! 2) (v V.! 3) (v V.! 4) (v V.! 5)-#endif  instance Random a => Random (Plucker a) where   random g = case random g of@@ -213,10 +190,8 @@   foldMap g (Plucker a b c d e f) =     g a `mappend` g b `mappend` g c `mappend` g d `mappend` g e `mappend` g f   {-# INLINE foldMap #-}-#if __GLASGOW_HASKELL__ >= 710   null _ = False   length _ =  6-#endif  instance Traversable Plucker where   traverse g (Plucker a b c d e f) =@@ -503,11 +478,7 @@               | Counterclockwise               -- ^ The lines pass each other counterclockwise               -- (left-handed screw).-                deriving (Eq, Show-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702-                         ,Generic-#endif-                         )+                deriving (Eq, Show,Generic)  -- | Check how two lines pass each other. @passes l1 l2@ describes -- @l2@ when looking down @l1@.@@ -628,9 +599,7 @@        M.basicUnsafeWrite a (o+3) w        M.basicUnsafeWrite a (o+4) v        M.basicUnsafeWrite a (o+5) u-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_Plucker _ v) = M.basicInitialize v-#endif  instance U.Unbox a => G.Vector U.Vector (Plucker a) where   basicUnsafeFreeze (MV_Plucker n v) = liftM ( V_Plucker n) (G.basicUnsafeFreeze v)@@ -678,8 +647,6 @@   put = serializeWith Cereal.put   get = deserializeWith Cereal.get --#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0)) instance Eq1 Plucker where   liftEq k (Plucker a1 b1 c1 d1 e1 f1)            (Plucker a2 b2 c2 d2 e2 f2)@@ -702,12 +669,6 @@ instance Show1 Plucker where   liftShowsPrec k _ z (Plucker a b c d e f) = showParen (z > 10) $      showString "Plucker " . k 11 a . showChar ' ' . k 11 b . showChar ' ' . k 11 c . showChar ' ' . k 11 d . showChar ' ' . k 11 e . showChar ' ' . k 11 f-#else-instance Eq1 Plucker where eq1 = (==)-instance Ord1 Plucker where compare1 = compare-instance Show1 Plucker where showsPrec1 = showsPrec-instance Read1 Plucker where readsPrec1 = readsPrec-#endif  instance Field1 (Plucker a) (Plucker a) a a where   _1 f (Plucker x y z u v w) = f x <&> \x' -> Plucker x' y z u v w
src/Linear/Quaternion.hs view
@@ -5,17 +5,10 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE CPP #-} {-# LANGUAGE TypeFamilies #-}-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DeriveGeneric #-}-#endif-#if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE DataKinds #-}-#endif--#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE DeriveLift #-}-#endif  #ifndef MIN_VERSION_hashable #define MIN_VERSION_hashable(x,y,z) 1@@ -76,42 +69,28 @@ import Data.Functor.Rep import qualified Data.Functor.WithIndex as WithIndex import Data.Hashable-#if (MIN_VERSION_hashable(1,2,5)) import Data.Hashable.Lifted-#endif #if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup (Semigroup(..)) #endif import Data.Serialize as Cereal import GHC.Arr (Ix(..)) import qualified Data.Foldable as F-#if !(MIN_VERSION_base(4,8,0))-import Data.Monoid (Monoid(..))-#endif import qualified Data.Traversable.WithIndex as WithIndex-#if __GLASGOW_HASKELL__ >= 707 import qualified Data.Vector as V-#endif import qualified Data.Vector.Generic.Mutable as M import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed.Base as U import Foreign.Ptr (castPtr, plusPtr) import Foreign.Storable (Storable(..))-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#endif-#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+import GHC.Generics (Generic, Generic1)+#if defined(MIN_VERSION_template_haskell) import Language.Haskell.TH.Syntax (Lift) #endif import Linear.Epsilon import Linear.Conjugate import Linear.Metric-#if __GLASGOW_HASKELL__ >= 707 import Linear.V-#endif import Linear.V2 import Linear.V3 import Linear.V4@@ -121,24 +100,17 @@  -- | Quaternions data Quaternion a = Quaternion !a {-# UNPACK #-}!(V3 a)-                    deriving (Eq,Ord,Read,Show,Data,Typeable-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702-                             ,Generic-#endif-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 706-                             ,Generic1-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+                    deriving (Eq,Ord,Read,Show,Data+                             ,Generic,Generic1+#if defined(MIN_VERSION_template_haskell)                              ,Lift #endif                              ) -#if __GLASGOW_HASKELL__ >= 707 instance Finite Quaternion where   type Size Quaternion = 4   toV (Quaternion a (V3 b c d)) = V (V.fromListN 4 [a, b, c, d])   fromV (V v) = Quaternion (v V.! 0) (V3 (v V.! 1) (v V.! 2) (v V.! 3))-#endif  instance Random a => Random (Quaternion a) where   random g = case random g of@@ -247,10 +219,8 @@   {-# INLINE foldMap #-}   foldr f z (Quaternion e v) = f e (F.foldr f z v)   {-# INLINE foldr #-}-#if __GLASGOW_HASKELL__ >= 710   null _ = False   length _ = 4-#endif  instance Traversable Quaternion where   traverse f (Quaternion e v) = Quaternion <$> f e <*> traverse f v@@ -307,11 +277,9 @@   hashWithSalt s (Quaternion a b) = s `hashWithSalt` a `hashWithSalt` b   {-# INLINE hashWithSalt #-} -#if (MIN_VERSION_hashable(1,2,5)) instance Hashable1 Quaternion where   liftHashWithSalt h s (Quaternion a b) = liftHashWithSalt h (h s a) b   {-# INLINE liftHashWithSalt #-}-#endif  qNaN :: RealFloat a => Quaternion a qNaN = Quaternion fNaN (V3 fNaN fNaN fNaN) where fNaN = 0/0@@ -649,9 +617,7 @@        M.basicUnsafeWrite v (o+1) y        M.basicUnsafeWrite v (o+2) z        M.basicUnsafeWrite v (o+3) w-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_Quaternion _ v) = M.basicInitialize v-#endif  instance U.Unbox a => G.Vector U.Vector (Quaternion a) where   basicUnsafeFreeze (MV_Quaternion n v) = liftM ( V_Quaternion n) (G.basicUnsafeFreeze v)@@ -694,7 +660,6 @@   put = serializeWith Cereal.put   get = deserializeWith Cereal.get -#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0)) instance Eq1 Quaternion where   liftEq f (Quaternion a b) (Quaternion c d) = f a c && liftEq f b d instance Ord1 Quaternion where@@ -703,12 +668,6 @@   liftShowsPrec f g d (Quaternion a b) = showsBinaryWith f (liftShowsPrec f g) "Quaternion" d a b instance Read1 Quaternion where   liftReadsPrec f g = readsData $ readsBinaryWith f (liftReadsPrec f g) "Quaternion" Quaternion-#else-instance Eq1 Quaternion where eq1 = (==)-instance Ord1 Quaternion where compare1 = compare-instance Show1 Quaternion where showsPrec1 = showsPrec-instance Read1 Quaternion where readsPrec1 = readsPrec-#endif  instance Field1 (Quaternion a) (Quaternion a) a a where   _1 f (Quaternion w xyz) = f w <&> \w' -> Quaternion w' xyz
src/Linear/Trace.hs view
@@ -1,12 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE DefaultSignatures #-}-#if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-}-#endif-#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ < 710 {-# LANGUAGE Trustworthy #-}-#endif --------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2012-2015 Edward Kmett@@ -33,9 +29,7 @@ import Linear.Quaternion import Linear.V import Linear.Vector-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ > 704 import Data.Complex-#endif import Data.Distributive import Data.Foldable as Foldable import Data.Functor.Bind as Bind@@ -95,13 +89,11 @@ instance Trace Plucker instance Trace Quaternion -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ > 704 instance Trace Complex where   trace ((a :+ _) :+ (_ :+ b)) = a + b   {-# INLINE trace #-}   diagonal ((a :+ _) :+ (_ :+ b)) = a :+ b   {-# INLINE diagonal #-}-#endif  instance (Trace f, Trace g) => Trace (Product f g) where   trace (Pair xx yy) = trace (pfst <$> xx) + trace (psnd <$> yy) where
src/Linear/V.hs view
@@ -9,14 +9,9 @@ {-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, UndecidableInstances #-} {-# LANGUAGE DeriveDataTypeable #-}-#if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-}-#endif-#if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE RoleAnnotations #-}-#define USE_TYPE_LITS 1-#endif {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DeriveGeneric #-} @@ -57,15 +52,11 @@   , Dim(..)   , reifyDim   , reifyVector-#if (MIN_VERSION_reflection(2,0,0)) && __GLASGOW_HASKELL__ >= 708   , reifyDimNat   , reifyVectorNat-#endif   , fromVector-#if __GLASGOW_HASKELL__ >= 707   , Finite(..)   , _V, _V'-#endif   ) where  import Control.Applicative@@ -77,9 +68,7 @@ import Control.Lens as Lens import Data.Binary as Binary import Data.Bytes.Serial-#if __GLASGOW_HASKELL__ >= 707 import Data.Complex-#endif import Data.Data import Data.Distributive import Data.Foldable as Foldable@@ -89,17 +78,10 @@ import Data.Functor.Rep as Rep import qualified Data.Functor.WithIndex as WithIndex import Data.Hashable-#if (MIN_VERSION_hashable(1,2,5)) import Data.Hashable.Lifted-#endif-#if __GLASGOW_HASKELL__ < 708-import Data.Proxy-#endif+import Data.Kind import Data.Reflection as R import Data.Serialize as Cereal-#if __GLASGOW_HASKELL__ < 710-import Data.Traversable (sequenceA)-#endif import qualified Data.Traversable.WithIndex as WithIndex import qualified Data.Vector as V import Data.Vector (Vector)@@ -108,24 +90,15 @@ import qualified Data.Vector.Generic.Mutable as M import Foreign.Ptr import Foreign.Storable-#ifdef USE_TYPE_LITS import GHC.TypeLits-#endif-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#endif-#if __GLASGOW_HASKELL__ >= 707-import GHC.Generics (Generic1)-#endif+import GHC.Generics (Generic, Generic1) #if !(MIN_VERSION_reflection(1,3,0)) && defined(MIN_VERSION_template_haskell) import Language.Haskell.TH #endif import Linear.Epsilon import Linear.Metric import Linear.Vector-#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0)) import Prelude as P-#endif #if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup #endif@@ -134,11 +107,10 @@ class Dim n where   reflectDim :: p n -> Int -#if __GLASGOW_HASKELL__ >= 707 type role V nominal representational  class Finite v where-  type Size (v :: * -> *) :: Nat -- this should allow kind k, for Reifies k Int+  type Size (v :: Type -> Type) :: Nat -- this should allow kind k, for Reifies k Int   toV :: v a -> V (Size v) a   default toV :: Foldable v => v a -> V (Size v) a   toV = V . V.fromList . Foldable.toList@@ -159,31 +131,24 @@   type Size (V n) = n   toV = id   fromV = id-#endif -newtype V n a = V { toVector :: V.Vector a } deriving (Eq,Ord,Show,Read,Typeable,NFData-                                                      , Generic--- GHC bug: https://ghc.haskell.org/trac/ghc/ticket/8468-#if __GLASGOW_HASKELL__ >= 707-                                                      ,Generic1-#endif+newtype V n a = V { toVector :: V.Vector a } deriving (Eq,Ord,Show,Read,NFData+                                                      ,Generic,Generic1                                                       )  dim :: forall n a. Dim n => V n a -> Int dim _ = reflectDim (Proxy :: Proxy n) {-# INLINE dim #-} -#ifdef USE_TYPE_LITS instance KnownNat n => Dim (n :: Nat) where   reflectDim = fromInteger . natVal   {-# INLINE reflectDim #-}-#endif  instance (Dim n, Random a) => Random (V n a) where   random = runState (V <$> V.replicateM (reflectDim (Proxy :: Proxy n)) (state random))   randomR (V ls,V hs) = runState (V <$> V.zipWithM (\l h -> state $ randomR (l,h)) ls hs) -data ReifiedDim (s :: *)+data ReifiedDim (s :: Type)  retagDim :: (Proxy s -> a) -> proxy (ReifiedDim s) -> a retagDim f _ = f Proxy@@ -193,8 +158,6 @@   reflectDim = retagDim reflect   {-# INLINE reflectDim #-} -#if (MIN_VERSION_reflection(2,0,0)) && __GLASGOW_HASKELL__ >= 708- reifyDimNat :: Int -> (forall (n :: Nat). KnownNat n => Proxy n -> r) -> r reifyDimNat i f = R.reifyNat (fromIntegral i) f {-# INLINE reifyDimNat #-}@@ -203,15 +166,13 @@ reifyVectorNat v f = reifyNat (fromIntegral $ V.length v) $ \(Proxy :: Proxy n) -> f (V v :: V n a) {-# INLINE reifyVectorNat #-} -#endif--reifyDim :: Int -> (forall (n :: *). Dim n => Proxy n -> r) -> r+reifyDim :: Int -> (forall (n :: Type). Dim n => Proxy n -> r) -> r reifyDim i f = R.reify i (go f) where   go :: (Proxy (ReifiedDim n) -> a) -> proxy n -> a   go g _ = g Proxy {-# INLINE reifyDim #-} -reifyVector :: forall a r. Vector a -> (forall (n :: *). Dim n => V n a -> r) -> r+reifyVector :: forall a r. Vector a -> (forall (n :: Type). Dim n => V n a -> r) -> r reifyVector v f = reifyDim (V.length v) $ \(Proxy :: Proxy n) -> f (V v :: V n a) {-# INLINE reifyVector #-} @@ -245,18 +206,14 @@   {-# INLINE foldr #-}   foldl f z (V as) = V.foldl f z as   {-# INLINE foldl #-}-#if __GLASGOW_HASKELL__ >= 706   foldr' f z (V as) = V.foldr' f z as   {-# INLINE foldr' #-}   foldl' f z (V as) = V.foldl' f z as   {-# INLINE foldl' #-}-#endif   foldr1 f (V as) = V.foldr1 f as   {-# INLINE foldr1 #-}   foldl1 f (V as) = V.foldl1 f as   {-# INLINE foldl1 #-}--#if __GLASGOW_HASKELL__ >= 710   length (V as) = V.length as   {-# INLINE length #-}   null (V as) = V.null as@@ -273,7 +230,6 @@   {-# INLINE sum #-}   product (V as) = V.product as   {-# INLINE product #-}-#endif  instance WithIndex.FoldableWithIndex Int (V n) where   ifoldMap f (V as) = ifoldMap f as@@ -397,13 +353,11 @@     V.foldl' (\s a -> s `hashWithSalt` a) s0 v       `hashWithSalt` V.length v -#if (MIN_VERSION_hashable(1,2,5)) instance Dim n => Hashable1 (V n) where   liftHashWithSalt h s0 (V v) =     V.foldl' (\s a -> h s a) s0 v       `hashWithSalt` V.length v   {-# INLINE liftHashWithSalt #-}-#endif  instance (Dim n, Storable a) => Storable (V n a) where   sizeOf _ = reflectDim (Proxy :: Proxy n) * sizeOf (undefined:: a)@@ -521,11 +475,7 @@ vDataType = mkDataType "Linear.V.V" [vConstr] {-# NOINLINE vDataType #-} -#if __GLASGOW_HASKELL__ >= 708-#define Typeable1 Typeable-#endif--instance (Typeable1 (V n), Typeable (V n a), Dim n, Data a) => Data (V n a) where+instance (Typeable (V n), Typeable (V n a), Dim n, Data a) => Data (V n a) where   gfoldl f z (V as) = z (V . V.fromList) `f` V.toList as   toConstr _ = vConstr   gunfold k z c = case constrIndex c of@@ -550,7 +500,6 @@   put = serializeWith Cereal.put   get = deserializeWith Cereal.get -#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0)) instance Eq1 (V n) where   liftEq f0 (V as0) (V bs0) = go f0 (V.toList as0) (V.toList bs0) where     go _ [] [] = True@@ -574,14 +523,7 @@     , (as, r2) <- g r1     , P.length as == reflectDim (Proxy :: Proxy n)     ]-#else-instance Dim n => Eq1 (V n) where eq1 = (==)-instance Dim n => Ord1 (V n) where compare1 = compare-instance Dim n => Show1 (V n) where showsPrec1 = showsPrec-instance Dim n => Read1 (V n) where readsPrec1 = readsPrec-#endif - data instance U.Vector    (V n a) =  V_VN {-# UNPACK #-} !Int !(U.Vector    a) data instance U.MVector s (V n a) = MV_VN {-# UNPACK #-} !Int !(U.MVector s a) instance (Dim n, U.Unbox a) => U.Unbox (V n a)@@ -610,10 +552,8 @@         a <- G.basicUnsafeIndexM vn j         M.basicUnsafeWrite v o a         go v vn d (o+1) (j+1)-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_VN _ v) = M.basicInitialize v   {-# INLINE basicInitialize #-}-#endif  instance (Dim n, U.Unbox a) => G.Vector U.Vector (V n a) where   {-# INLINE basicUnsafeFreeze #-}@@ -634,7 +574,6 @@ vLens i = \f (V v) -> f (v V.! i) <&> \a -> V (v V.// [(i, a)]) {-# INLINE vLens #-} -#ifdef USE_TYPE_LITS instance ( 1 <= n) => Field1  (V n a) (V n a) a a where _1  = vLens  0 instance ( 2 <= n) => Field2  (V n a) (V n a) a a where _2  = vLens  1 instance ( 3 <= n) => Field3  (V n a) (V n a) a a where _3  = vLens  2@@ -654,4 +593,3 @@ instance (17 <= n) => Field17 (V n a) (V n a) a a where _17 = vLens 16 instance (18 <= n) => Field18 (V n a) (V n a) a a where _18 = vLens 17 instance (19 <= n) => Field19 (V n a) (V n a) a a where _19 = vLens 18-#endif
src/Linear/V0.hs view
@@ -4,19 +4,10 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}--#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE Trustworthy #-}-#endif--#if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE DataKinds #-}-#endif--#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE DeriveLift #-}-#endif  #ifndef MIN_VERSION_hashable #define MIN_VERSION_hashable(x,y,z) 1@@ -65,26 +56,17 @@ import Data.Functor.Rep import qualified Data.Functor.WithIndex as WithIndex import Data.Hashable-#if (MIN_VERSION_hashable(1,2,5)) import Data.Hashable.Lifted-#endif import Data.Ix #if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup #endif import Data.Serialize -- cereal import qualified Data.Traversable.WithIndex as WithIndex-#if __GLASGOW_HASKELL__ >= 707 import qualified Data.Vector as V-#endif import Foreign.Storable (Storable(..))-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#endif-#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+import GHC.Generics (Generic, Generic1)+#if defined(MIN_VERSION_template_haskell) import Language.Haskell.TH.Syntax (Lift) #endif import qualified Data.Vector.Generic.Mutable as M@@ -93,9 +75,7 @@ import Linear.Metric import Linear.Epsilon import Linear.Vector-#if __GLASGOW_HASKELL__ >= 707 import Linear.V-#endif import System.Random (Random(..)) import Prelude hiding (sum) @@ -113,24 +93,17 @@ -- >>> V0 + V0 -- V0 ---data V0 a = V0 deriving (Eq,Ord,Show,Read,Ix,Enum,Data,Typeable-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702-                        ,Generic-#endif-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 706-                        ,Generic1-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+data V0 a = V0 deriving (Eq,Ord,Show,Read,Ix,Enum,Data+                        ,Generic,Generic1+#if defined(MIN_VERSION_template_haskell)                         ,Lift #endif                         ) -#if __GLASGOW_HASKELL__ >= 707 instance Finite V0 where   type Size V0 = 0   toV _ = V V.empty   fromV _ = V0-#endif  instance Random (V0 a) where   random g = (V0, g)@@ -163,10 +136,8 @@ instance Foldable V0 where   foldMap _ V0 = mempty   {-# INLINE foldMap #-}-#if __GLASGOW_HASKELL__ >= 710   null _ = True   length _ = 0-#endif  instance Traversable V0 where   traverse _ V0 = pure V0@@ -282,18 +253,14 @@   {-# 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 #-} -#if (MIN_VERSION_hashable(1,2,5)) instance Hashable1 V0 where   liftHashWithSalt _ s V0 = s   {-# INLINE liftHashWithSalt #-}-#endif  instance Epsilon (V0 a) where   nearZero _ = True@@ -362,10 +329,8 @@   basicUnsafeNew n = return (MV_V0 n)   basicUnsafeRead _ _ = return V0   basicUnsafeWrite _ _ _ = return ()-#if MIN_VERSION_vector(0,11,0)   basicInitialize _ = return ()   {-# INLINE basicInitialize #-}-#endif  instance G.Vector U.Vector (V0 a) where   {-# INLINE basicUnsafeFreeze #-}@@ -396,7 +361,6 @@ instance NFData (V0 a) where   rnf V0 = () -#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0)) instance Eq1 V0   where   liftEq _ _ _ = True instance Ord1 V0  where@@ -405,9 +369,3 @@   liftShowsPrec _ _ = showsPrec instance Read1 V0 where   liftReadsPrec _ _ = readsPrec-#else-instance Eq1 V0   where eq1 = (==)-instance Ord1 V0  where compare1 = compare-instance Show1 V0 where showsPrec1 = showsPrec-instance Read1 V0 where readsPrec1 = readsPrec-#endif
src/Linear/V1.hs view
@@ -8,17 +8,10 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ScopedTypeVariables #-}-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DeriveGeneric #-}-#endif-#if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE DataKinds #-}-#endif--#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE DeriveLift #-}-#endif  #ifndef MIN_VERSION_hashable #define MIN_VERSION_hashable(x,y,z) 1@@ -71,24 +64,15 @@ import Data.Functor.Rep import qualified Data.Functor.WithIndex as WithIndex import Data.Hashable-#if (MIN_VERSION_hashable(1,2,5)) import Data.Hashable.Lifted-#endif import Data.Semigroup.Foldable import qualified Data.Traversable.WithIndex as WithIndex-#if __GLASGOW_HASKELL__ >= 707 import qualified Data.Vector as V import Linear.V-#endif import Foreign.Storable (Storable) import GHC.Arr (Ix(..))-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#endif-#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+import GHC.Generics (Generic, Generic1)+#if defined(MIN_VERSION_template_haskell) import Language.Haskell.TH.Syntax (Lift) #endif import Linear.Metric@@ -124,35 +108,29 @@ -- >>> sum (V1 2) -- 2 ---data V2 a = V2 !a !a deriving (Eq,Ord,Show,Read,Data,Typeable)+--data V2 a = V2 !a !a deriving (Eq,Ord,Show,Read,Data) newtype V1 a = V1 a-  deriving (Eq,Ord,Show,Read,Data,Typeable,+  deriving (Eq,Ord,Show,Read,Data,             Functor,Traversable,             Epsilon,Storable,NFData-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702-           ,Generic-#endif-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 706-           ,Generic1-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+           ,Generic,Generic1+#if defined(MIN_VERSION_template_haskell)            ,Lift #endif            )  instance Foldable V1 where   foldMap f (V1 a) = f a-#if __GLASGOW_HASKELL__ >= 710+#if MIN_VERSION_base(4,13,0)+  foldMap' f (V1 a) = f a+#endif   null _ = False   length _ = 1-#endif -#if __GLASGOW_HASKELL__ >= 707 instance Finite V1 where   type Size V1 = 1   toV (V1 a) = V (V.singleton a)   fromV (V v) = V1 (v V.! 0)-#endif  instance Foldable1 V1 where   foldMap1 f (V1 a) = f a@@ -255,16 +233,12 @@     {-# INLINE acosh #-}  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 -#if (MIN_VERSION_hashable(1,2,5)) instance Hashable1 V1 where   liftHashWithSalt h s (V1 a) = h s a   {-# INLINE liftHashWithSalt #-}-#endif  instance Metric V1 where   dot (V1 a) (V1 b) = a * b@@ -362,10 +336,8 @@   basicUnsafeNew n = liftM MV_V1 (M.basicUnsafeNew n)   basicUnsafeRead (MV_V1 v) i = liftM V1 (M.basicUnsafeRead v i)   basicUnsafeWrite (MV_V1 v) i (V1 x) = M.basicUnsafeWrite v i x-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_V1 v) = M.basicInitialize v   {-# INLINE basicInitialize #-}-#endif  instance U.Unbox a => G.Vector U.Vector (V1 a) where   {-# INLINE basicUnsafeFreeze #-}@@ -415,7 +387,6 @@   randomR (V1 a, V1 b) g = case randomR (a, b) g of (a', g') -> (V1 a', g')   randomRs (V1 a, V1 b) g = V1 <$> randomRs (a, b) g -#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0)) instance Eq1 V1 where   liftEq f (V1 a) (V1 b) = f a b instance Ord1 V1 where@@ -424,12 +395,6 @@   liftShowsPrec f _ d (V1 a) = showParen (d >= 10) $ showString "V1 " . f d a instance Read1 V1 where   liftReadsPrec f _ = readsData $ readsUnaryWith f "V1" V1-#else-instance Eq1 V1 where eq1 = (==)-instance Ord1 V1 where compare1 = compare-instance Show1 V1 where showsPrec1 = showsPrec-instance Read1 V1 where readsPrec1 = readsPrec-#endif  instance Field1 (V1 a) (V1 b) a b where   _1 f (V1 x) = V1 <$> f x
src/Linear/V2.hs view
@@ -5,17 +5,10 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DeriveGeneric #-}-#endif-#if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE DataKinds #-}-#endif--#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE DeriveLift #-}-#endif  #ifndef MIN_VERSION_hashable #define MIN_VERSION_hashable(x,y,z) 1@@ -73,26 +66,17 @@ import Data.Functor.Rep import qualified Data.Functor.WithIndex as WithIndex import Data.Hashable-#if (MIN_VERSION_hashable(1,2,5)) import Data.Hashable.Lifted-#endif import Data.Semigroup import Data.Semigroup.Foldable import Data.Serialize as Cereal import qualified Data.Traversable.WithIndex as WithIndex-#if __GLASGOW_HASKELL__ >= 707 import qualified Data.Vector as V-#endif import Foreign.Ptr (castPtr) import Foreign.Storable (Storable(..)) import GHC.Arr (Ix(..))-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#endif-#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+import GHC.Generics (Generic, Generic1)+#if defined(MIN_VERSION_template_haskell) import Language.Haskell.TH.Syntax (Lift) #endif import qualified Data.Vector.Generic.Mutable as M@@ -100,9 +84,7 @@ import qualified Data.Vector.Unboxed.Base as U import Linear.Metric import Linear.Epsilon-#if __GLASGOW_HASKELL__ >= 707 import Linear.V-#endif import Linear.Vector import Linear.V1 (R1(..),ex) import Prelude hiding (sum)@@ -129,24 +111,17 @@ -- 3  data V2 a = V2 !a !a deriving-  (Eq,Ord,Show,Read,Data,Typeable-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702-  ,Generic-#endif-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 706-  ,Generic1-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+  (Eq,Ord,Show,Read,Data+  ,Generic,Generic1+#if defined(MIN_VERSION_template_haskell)   ,Lift #endif   ) -#if __GLASGOW_HASKELL__ >= 707 instance Finite V2 where   type Size V2 = 2   toV (V2 a b) = V (V.fromListN 2 [a,b])   fromV (V v) = V2 (v V.! 0) (v V.! 1)-#endif  instance Random a => Random (V2 a) where   random g = case random g of@@ -167,10 +142,12 @@ instance Foldable V2 where   foldMap f (V2 a b) = f a `mappend` f b   {-# INLINE foldMap #-}-#if __GLASGOW_HASKELL__ >= 710+#if MIN_VERSION_base(4,13,0)+  foldMap' f (V2 a b) = f a `mappend` f b+  {-# INLINE foldMap' #-}+#endif   null _ = False   length _ = 2-#endif  instance Traversable V2 where   traverse f (V2 a b) = V2 <$> f a <*> f b@@ -198,11 +175,9 @@   hashWithSalt s (V2 a b) = s `hashWithSalt` a `hashWithSalt` b   {-# INLINE hashWithSalt #-} -#if (MIN_VERSION_hashable(1,2,5)) instance Hashable1 V2 where   liftHashWithSalt h s (V2 a b) = s `h` a `h` b   {-# INLINE liftHashWithSalt #-}-#endif  instance Additive V2 where   zero = pure 0@@ -432,10 +407,8 @@     do let o = 2*i        M.basicUnsafeWrite v o     x        M.basicUnsafeWrite v (o+1) y-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_V2 _ v) = M.basicInitialize v   {-# INLINE basicInitialize #-}-#endif  instance U.Unbox a => G.Vector U.Vector (V2 a) where   {-# INLINE basicUnsafeFreeze #-}@@ -503,7 +476,6 @@   put = serializeWith Cereal.put   get = deserializeWith Cereal.get -#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0)) instance Eq1 V2 where   liftEq f (V2 a b) (V2 c d) = f a c && f b d instance Ord1 V2 where@@ -512,12 +484,6 @@   liftReadsPrec f _ = readsData $ readsBinaryWith f f "V2" V2 instance Show1 V2 where   liftShowsPrec f _ d (V2 a b) = showsBinaryWith f f "V2" d a b-#else-instance Eq1 V2 where eq1 = (==)-instance Ord1 V2 where compare1 = compare-instance Show1 V2 where showsPrec1 = showsPrec-instance Read1 V2 where readsPrec1 = readsPrec-#endif  instance Field1 (V2 a) (V2 a) a a where   _1 f (V2 x y) = f x <&> \x' -> V2 x' y
src/Linear/V3.hs view
@@ -5,17 +5,10 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DeriveGeneric #-}-#endif-#if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE DataKinds #-}-#endif--#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE DeriveLift #-}-#endif  #ifndef MIN_VERSION_hashable #define MIN_VERSION_hashable(x,y,z) 1@@ -69,38 +62,27 @@ import Data.Functor.Rep import qualified Data.Functor.WithIndex as WithIndex import Data.Hashable-#if (MIN_VERSION_hashable(1,2,5)) import Data.Hashable.Lifted-#endif #if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup #endif import Data.Semigroup.Foldable import Data.Serialize as Cereal -- cereal import qualified Data.Traversable.WithIndex as WithIndex-#if __GLASGOW_HASKELL__ >= 707 import qualified Data.Vector as V-#endif import qualified Data.Vector.Generic.Mutable as M import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed.Base as U import Foreign.Ptr (castPtr) import Foreign.Storable (Storable(..)) import GHC.Arr (Ix(..))-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#endif-#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+import GHC.Generics (Generic, Generic1)+#if defined(MIN_VERSION_template_haskell) import Language.Haskell.TH.Syntax (Lift) #endif import Linear.Epsilon import Linear.Metric-#if __GLASGOW_HASKELL__ >= 707 import Linear.V-#endif import Linear.V2 import Linear.Vector import System.Random (Random(..))@@ -109,24 +91,17 @@ -- >>> import Control.Lens hiding (index)  -- | A 3-dimensional vector-data V3 a = V3 !a !a !a deriving (Eq,Ord,Show,Read,Data,Typeable-#if __GLASGOW_HASKELL__ >= 702-                                 ,Generic-#endif-#if __GLASGOW_HASKELL__ >= 706-                                 ,Generic1-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+data V3 a = V3 !a !a !a deriving (Eq,Ord,Show,Read,Data+                                 ,Generic,Generic1+#if defined(MIN_VERSION_template_haskell)                                  ,Lift #endif                                  ) -#if __GLASGOW_HASKELL__ >= 707 instance Finite V3 where   type Size V3 = 3   toV (V3 a b c) = V (V.fromListN 3 [a,b,c])   fromV (V v) = V3 (v V.! 0) (v V.! 1) (v V.! 2)-#endif  instance Functor V3 where   fmap f (V3 a b c) = V3 (f a) (f b) (f c)@@ -137,10 +112,12 @@ instance Foldable V3 where   foldMap f (V3 a b c) = f a `mappend` f b `mappend` f c   {-# INLINE foldMap #-}-#if __GLASGOW_HASKELL__ >= 710+#if MIN_VERSION_base(4,13,0)+  foldMap' f (V3 a b c) = (f a `mappend` f b) `mappend` f c+  {-# INLINE foldMap' #-}+#endif   null _ = False   length _ = 3-#endif  instance Random a => Random (V3 a) where   random g = case random g of@@ -266,11 +243,9 @@   hashWithSalt s (V3 a b c) = s `hashWithSalt` a `hashWithSalt` b `hashWithSalt` c   {-# INLINE hashWithSalt #-} -#if (MIN_VERSION_hashable(1,2,5)) instance Hashable1 V3 where   liftHashWithSalt h s (V3 a b c) = s `h` a `h` b `h` c   {-# INLINE liftHashWithSalt #-}-#endif  instance Metric V3 where   dot (V3 a b c) (V3 d e f) = a * d + b * e + c * f@@ -450,10 +425,8 @@        M.basicUnsafeWrite v o     x        M.basicUnsafeWrite v (o+1) y        M.basicUnsafeWrite v (o+2) z-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_V3 _ v) = M.basicInitialize v   {-# INLINE basicInitialize #-}-#endif  instance U.Unbox a => G.Vector U.Vector (V3 a) where   {-# INLINE basicUnsafeFreeze #-}@@ -505,7 +478,6 @@   put = serializeWith Cereal.put   get = deserializeWith Cereal.get -#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0)) instance Eq1 V3 where   liftEq k (V3 a b c) (V3 d e f) = k a d && k b e && k c f instance Ord1 V3 where@@ -521,12 +493,6 @@ instance Show1 V3 where   liftShowsPrec f _ d (V3 a b c) = showParen (d > 10) $      showString "V3 " . f 11 a . showChar ' ' . f 11 b . showChar ' ' . f 11 c-#else-instance Eq1 V3 where eq1 = (==)-instance Ord1 V3 where compare1 = compare-instance Show1 V3 where showsPrec1 = showsPrec-instance Read1 V3 where readsPrec1 = readsPrec-#endif  instance Field1 (V3 a) (V3 a) a a where   _1 f (V3 x y z) = f x <&> \x' -> V3 x' y z
src/Linear/V4.hs view
@@ -5,17 +5,10 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DeriveGeneric #-}-#endif-#if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE DataKinds #-}-#endif--#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE DeriveLift #-}-#endif  #ifndef MIN_VERSION_hashable #define MIN_VERSION_hashable(x,y,z) 1@@ -75,38 +68,27 @@ import Data.Functor.Rep import qualified Data.Functor.WithIndex as WithIndex import Data.Hashable-#if (MIN_VERSION_hashable(1,2,5)) import Data.Hashable.Lifted-#endif #if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup #endif import Data.Semigroup.Foldable import Data.Serialize as Cereal import qualified Data.Traversable.WithIndex as WithIndex-#if __GLASGOW_HASKELL__ >= 707 import qualified Data.Vector as V-#endif import qualified Data.Vector.Generic.Mutable as M import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed.Base as U import Foreign.Ptr (castPtr) import Foreign.Storable (Storable(..)) import GHC.Arr (Ix(..))-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#endif-#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+import GHC.Generics (Generic, Generic1)+#if defined(MIN_VERSION_template_haskell) import Language.Haskell.TH.Syntax (Lift) #endif import Linear.Epsilon import Linear.Metric-#if __GLASGOW_HASKELL__ >= 707 import Linear.V-#endif import Linear.V2 import Linear.V3 import Linear.Vector@@ -116,24 +98,17 @@ -- >>> import Control.Lens hiding (index)  -- | A 4-dimensional vector.-data V4 a = V4 !a !a !a !a deriving (Eq,Ord,Show,Read,Data,Typeable-#if __GLASGOW_HASKELL__ >= 702-                                    ,Generic-#endif-#if __GLASGOW_HASKELL__ >= 706-                                    ,Generic1-#endif-#if __GLASGOW_HASKELL__ >= 800 && defined(MIN_VERSION_template_haskell)+data V4 a = V4 !a !a !a !a deriving (Eq,Ord,Show,Read,Data+                                    ,Generic,Generic1+#if defined(MIN_VERSION_template_haskell)                                     ,Lift #endif                                     ) -#if __GLASGOW_HASKELL__ >= 707 instance Finite V4 where   type Size V4 = 4   toV (V4 a b c d) = V (V.fromListN 4 [a,b,c,d])   fromV (V v) = V4 (v V.! 0) (v V.! 1) (v V.! 2) (v V.! 3)-#endif  instance Functor V4 where   fmap f (V4 a b c d) = V4 (f a) (f b) (f c) (f d)@@ -144,10 +119,12 @@ instance Foldable V4 where   foldMap f (V4 a b c d) = f a `mappend` f b `mappend` f c `mappend` f d   {-# INLINE foldMap #-}-#if __GLASGOW_HASKELL__ >= 710+#if MIN_VERSION_base(4,13,0)+  foldMap' f (V4 a b c d) = ((f a `mappend` f b) `mappend` f c) `mappend` f d+  {-# INLINE foldMap' #-}+#endif   null _ = False   length _ = 4-#endif  instance Random a => Random (V4 a) where   random g = case random g of@@ -288,11 +265,9 @@   hashWithSalt s (V4 a b c d) = s `hashWithSalt` a `hashWithSalt` b `hashWithSalt` c `hashWithSalt` d   {-# INLINE hashWithSalt #-} -#if (MIN_VERSION_hashable(1,2,5)) instance Hashable1 V4 where   liftHashWithSalt h s (V4 a b c d) = s `h` a `h` b `h` c `h` d   {-# INLINE liftHashWithSalt #-}-#endif  -- | A space that distinguishes orthogonal basis vectors '_x', '_y', '_z', '_w'. (It may have more.) class R3 t => R4 t where@@ -593,9 +568,7 @@        M.basicUnsafeWrite v (o+1) y        M.basicUnsafeWrite v (o+2) z        M.basicUnsafeWrite v (o+3) w-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_V4 _ v) = M.basicInitialize v-#endif  instance U.Unbox a => G.Vector U.Vector (V4 a) where   basicUnsafeFreeze (MV_V4 n v) = liftM ( V_V4 n) (G.basicUnsafeFreeze v)@@ -644,7 +617,6 @@   put = serializeWith Cereal.put   get = deserializeWith Cereal.get -#if (MIN_VERSION_transformers(0,5,0)) || !(MIN_VERSION_transformers(0,4,0)) instance Eq1 V4 where   liftEq k (V4 a b c d) (V4 e f g h) = k a e && k b f && k c g && k d h instance Ord1 V4 where@@ -661,12 +633,6 @@ instance Show1 V4 where   liftShowsPrec f _ z (V4 a b c d) = showParen (z > 10) $      showString "V4 " . f 11 a . showChar ' ' . f 11 b . showChar ' ' . f 11 c . showChar ' ' . f 11 d-#else-instance Eq1 V4 where eq1 = (==)-instance Ord1 V4 where compare1 = compare-instance Show1 V4 where showsPrec1 = showsPrec-instance Read1 V4 where readsPrec1 = readsPrec-#endif  instance Field1 (V4 a) (V4 a) a a where   _1 f (V4 x y z w) = f x <&> \x' -> V4 x' y z w
src/Linear/Vector.hs view
@@ -4,11 +4,8 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} {-# LANGUAGE DefaultSignatures #-}-#define USE_GHC_GENERICS-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2012-2015 Edward Kmett@@ -37,26 +34,17 @@ import Control.Applicative import Control.Lens import Data.Complex-#if __GLASGOW_HASKELL__ < 710-import Data.Foldable as Foldable (Foldable, forM_, foldl')-#else import Data.Foldable as Foldable (forM_, foldl')-#endif import Data.Functor.Compose import Data.Functor.Product import Data.HashMap.Lazy as HashMap import Data.Hashable import Data.IntMap as IntMap import Data.Map as Map-#if __GLASGOW_HASKELL__ < 710-import Data.Monoid (mempty)-#endif import qualified Data.Vector as Vector import Data.Vector (Vector) import qualified Data.Vector.Mutable as Mutable-#ifdef USE_GHC_GENERICS import GHC.Generics-#endif import Linear.Instances ()  -- $setup@@ -68,7 +56,6 @@ infixl 6 ^+^, ^-^ infixl 7 ^*, *^, ^/ -#ifdef USE_GHC_GENERICS class GAdditive f where   gzero :: Num a => f a   gliftU2 :: (a -> a -> a) -> f a -> f a -> f a@@ -120,18 +107,15 @@   {-# INLINE gliftU2 #-}   gliftI2 f (Par1 a) (Par1 b) = Par1 (f a b)   {-# INLINE gliftI2 #-}-#endif  -- | A vector is an additive group with additional structure. class Functor f => Additive f where   -- | The zero vector   zero :: Num a => f a-#ifdef USE_GHC_GENERICS #ifndef HLINT   default zero :: (GAdditive (Rep1 f), Generic1 f, Num a) => f a   zero = to1 gzero #endif-#endif    -- | Compute the sum of two vectors   --@@ -159,13 +143,11 @@   --   -- * For a sparse vector this is equivalent to 'unionWith'.   liftU2 :: (a -> a -> a) -> f a -> f a -> f a-#ifdef USE_GHC_GENERICS #ifndef HLINT   default liftU2 :: Applicative f => (a -> a -> a) -> f a -> f a -> f a   liftU2 = liftA2   {-# INLINE liftU2 #-} #endif-#endif    -- | Apply a function to the components of two vectors.   --@@ -173,12 +155,10 @@   --   -- * For a sparse vector this is equivalent to 'intersectionWith'.   liftI2 :: (a -> b -> c) -> f a -> f b -> f c-#ifdef USE_GHC_GENERICS #ifndef HLINT   default liftI2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c   liftI2 = liftA2   {-# INLINE liftI2 #-}-#endif #endif  instance (Additive f, Additive g) => Additive (Product f g) where
tests/Binary.hs view
@@ -1,9 +1,5 @@-{-# LANGUAGE CPP #-} module Binary (tests) where -#if !(MIN_VERSION_base(4,8,0))-import Control.Applicative-#endif import Data.Binary.Put import Data.Binary.Get import Linear
tests/UnitTests.hs view
@@ -4,16 +4,12 @@ import Test.Framework.Providers.HUnit import qualified Plucker import qualified Binary-#if __GLASGOW_HASKELL__ >= 707 import qualified V-#endif  tests :: [Test] tests = [ testGroup "Plucker" $ hUnitTestToTests Plucker.tests         , testGroup "Binary" $ hUnitTestToTests Binary.tests-#if __GLASGOW_HASKELL__ >= 707         , testGroup "V" $ hUnitTestToTests V.tests-#endif         ]  main :: IO ()