packages feed

free-vector-spaces 0.1.5.1 → 0.1.5.2

raw patch · 5 files changed

+106/−42 lines, 5 filesdep +template-haskelldep ~lineardep ~vector-spacePVP ok

version bump matches the API change (PVP)

Dependencies added: template-haskell

Dependency ranges changed: linear, vector-space

API changes (from Hackage documentation)

Files

Data/VectorSpace/Free.hs view
@@ -11,7 +11,7 @@ {-# LANGUAGE TypeOperators           #-} {-# LANGUAGE FlexibleInstances       #-} {-# LANGUAGE FlexibleContexts        #-}-{-# LANGUAGE CPP                     #-}+{-# LANGUAGE TemplateHaskell         #-} {-# LANGUAGE ConstrainedClassMethods #-} {-# LANGUAGE DefaultSignatures       #-} {-# LANGUAGE ScopedTypeVariables     #-}@@ -45,6 +45,7 @@ import Data.VectorSpace.Free.Class import Data.VectorSpace.Free.FiniteSupportedSequence (FinSuppSeq) import Data.VectorSpace.Free.Sequence (Sequence)+import Data.VectorSpace.Free.TH import Data.Basis  import Data.MemoTrie@@ -77,51 +78,61 @@ vDecomp :: FoldableWithIndex (L.E v) v => v s -> [(L.E v, s)] vDecomp = ifoldr (\b s l -> (b,s):l) [] -#define portFinDV(v)                              \-instance Num s => AffineSpace (v s) where {        \-  type Diff (v s) = v s;                            \-  (.-.) = (L.^-^);                                   \-  (.+^) = (L.^+^) };                                  \-instance Num s => AdditiveGroup (v s) where {          \-  zeroV = L.zero;                                       \-  (^+^) = (L.^+^);                                       \-  negateV = L.negated };                                  \-instance Num s => VectorSpace (v s) where {                \-  type Scalar (v s) = s;                                    \-  (*^) = (L.*^) };                                           \-instance (Num s, AdditiveGroup s) => InnerSpace (v s) where { \-  (<.>) = L.dot };                                             \-instance (Num s, AdditiveGroup s) => HasBasis (v s) where {     \-  type Basis (v s) = L.E v;                                      \-  decompose = vDecomp;                                            \-  basisValue x = L.unit (L.el x :: Lens' (v s) s);                 \-  decompose' w (L.E le) = w^.le } -portFinDV(V0)-portFinDV(V1)-portFinDV(V2)-portFinDV(V3)-portFinDV(V4) -#define portFinDP(v)                                 \-instance Num s => AffineSpace (LA.Point v s) where {  \-  type Diff (LA.Point v s) = v s;                      \-  (.-.) = (LA..-.);                                     \-  (.+^) = (LA..+^) }+-- #define portFinDV(v)                              \+-- instance Num s => AffineSpace (v s) where {        \+--   type Diff (v s) = v s;                            \+--   (.-.) = (L.^-^);                                   \+--   (.+^) = (L.^+^) };                                  \+-- instance Num s => AdditiveGroup (v s) where {          \+--   zeroV = L.zero;                                       \+--   (^+^) = (L.^+^);                                       \+--   negateV = L.negated };                                  \+-- instance Num s => VectorSpace (v s) where {                \+--   type Scalar (v s) = s;                                    \+--   (*^) = (L.*^) };                                           \+-- instance (Num s, AdditiveGroup s) => InnerSpace (v s) where { \+--   (<.>) = L.dot };                                             \+-- instance (Num s, AdditiveGroup s) => HasBasis (v s) where {     \+--   type Basis (v s) = L.E v;                                      \+--   decompose = vDecomp;                                            \+--   basisValue x = L.unit (L.el x :: Lens' (v s) s);                 +--   decompose' w (L.E le) = w^.le } -portFinDP(V0)-portFinDP(V1)-portFinDP(V2)+portFinDV ''V0+portFinDV ''V1+portFinDV ''V2+portFinDV ''V3+portFinDV ''V4+++-- portFinDP t = [d|+--   instance Num s => AffineSpace (LA.Point $v s) where+--     type Diff (LA.Point $v s) = $v s+--     (.-.) = (LA..-.)+--     (.+^) = (LA..+^) +--     |]+--       where  v = litT ( strTyLit t )+-- #define portFinDP(v)                                 \+-- instance Num s => AffineSpace (LA.Point v s) where {  \+--   type Diff (LA.Point v s) = v s;                      \+--   (.-.) = (LA..-.);                                     \+--   (.+^) = (LA..+^) }++portFinDP ''V0+portFinDP ''V1+portFinDP ''V2 instance Num s => HasCross2 (V2 s) where   cross2 (V2 x y) = V2 (-y) x -portFinDP(V3)+portFinDP ''V3 instance Num s => HasCross3 (V3 s) where   V3 ax ay az `cross3` V3 bx by bz = V3 (ay * bz - az * by)                                         (az * bx - ax * bz)                                         (ax * by - ay * bx) -portFinDP(V4)+portFinDP ''V4   instance HasTrie (L.E V0) where
Data/VectorSpace/Free/FiniteSupportedSequence.hs view
@@ -10,7 +10,6 @@ {-# LANGUAGE TypeFamilies            #-} {-# LANGUAGE FlexibleInstances       #-} {-# LANGUAGE FlexibleContexts        #-}-{-# LANGUAGE CPP                     #-} {-# LANGUAGE ConstrainedClassMethods #-} {-# LANGUAGE MultiWayIf              #-} {-# LANGUAGE ScopedTypeVariables     #-}
Data/VectorSpace/Free/Sequence.hs view
@@ -10,7 +10,6 @@ {-# LANGUAGE TypeFamilies            #-} {-# LANGUAGE FlexibleInstances       #-} {-# LANGUAGE FlexibleContexts        #-}-{-# LANGUAGE CPP                     #-} {-# LANGUAGE ConstrainedClassMethods #-} {-# LANGUAGE StandaloneDeriving      #-} {-# LANGUAGE DeriveFunctor           #-}
+ Data/VectorSpace/Free/TH.hs view
@@ -0,0 +1,52 @@+{-# LANGUAGE TemplateHaskell         #-}++module Data.VectorSpace.Free.TH where++import Data.AffineSpace+import Data.Basis+import Data.VectorSpace+import qualified Linear as L+import Control.Lens (Lens')+import           Language.Haskell.TH+import qualified Linear.Affine as LA++-- | Generate 'VectorSpace' style instances from representable-functor ones.+--   Intended mostly for use with the types 'L.V1' ... 'L.V4' etc..+-- +--   This macro generates instances for the classes 'AffineSpace', 'AdditiveGroup',+--   'VectorSpace', 'InnerSpace' and 'Basis'.+portFinDV t = [d|+  instance Num s => AffineSpace ($v s) where      +    type Diff ($v s) = $v s                        +    (.-.) = (L.^-^)                               +    (.+^) = (L.^+^)++  instance Num s => AdditiveGroup ($v s) where+    zeroV = L.zero                                 +    (^+^) = (L.^+^)                                       +    negateV = L.negated++  instance Num s => VectorSpace ($v s) where             +    type Scalar ($v s) = s                                 +    (*^) = (L.*^)++  instance (Num s, AdditiveGroup s) => InnerSpace ($v s) where+    (<.>) = L.dot++  instance (Num s, AdditiveGroup s) => HasBasis ($v s) where+    type Basis ($v s) = L.E $v                                    +    decompose = vDecomp                                           +    basisValue x = L.unit (L.el x :: Lens' ($v s) s)                 +    decompose' w (L.E le) = w^.le+  |]+  where+    v = conT t++-- | Generate an 'AffineSpace' instance for the 'LA.Point' of a representable functor.+portFinDP t = [d|+  instance Num s => AffineSpace (LA.Point $v s) where+    type Diff (LA.Point $v s) = $v s+    (.-.) = (LA..-.)+    (.+^) = (LA..+^) +    |]+      where  v = conT t
free-vector-spaces.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                free-vector-spaces-version:             0.1.5.1+version:             0.1.5.2 synopsis:            Instantiate the classes from the vector-space package with types from linear description:         The <http://hackage.haskell.org/package/linear/ linear> package offers efficient                      vector types — where vector means /element of a free vector space/, i.e.@@ -48,9 +48,10 @@  library   exposed-modules:     Data.VectorSpace.Free-                       , Data.VectorSpace.Free.FiniteSupportedSequence-                       , Data.VectorSpace.Free.Sequence-  other-modules:       Data.VectorSpace.Free.Class+                      , Data.VectorSpace.Free.FiniteSupportedSequence+                      , Data.VectorSpace.Free.Sequence+  other-modules:        Data.VectorSpace.Free.Class+                      , Data.VectorSpace.Free.TH   -- other-extensions:       build-depends:       base >=4.6 && <5.1,                        vector-space >=0.11 && <0.18,@@ -58,7 +59,9 @@                        linear >=1.18 && <1.23,                        lens >= 4 && < 6,                        vector,-                       pragmatic-show >=0.1.2 && <0.2+                       pragmatic-show >=0.1.2 && <0.2,+                       template-haskell   ghc-options:         -O2   -- hs-source-dirs:         default-language:    Haskell2010+  -- ghc-options: -cpp  -pgmPcpphs  -optP--cpps