packages feed

linear 1.19 → 1.19.1

raw patch · 3 files changed

+56/−2 lines, 3 filesdep ~basedep ~reflection

Dependency ranges changed: base, reflection

Files

CHANGELOG.markdown view
@@ -1,3 +1,7 @@+1.19.1+------+* `reflection` 2 support+ 1.19 ---- * Change the Ixed instance for `Linear.V` to use `Int` as the index type. This makes `V n` a _lot_ easier to use.
linear.cabal view
@@ -1,6 +1,6 @@ name:          linear category:      Math, Algebra-version:       1.19+version:       1.19.1 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE@@ -49,7 +49,7 @@     ghc-prim,     hashable             >= 1.1   && < 1.3,     lens                 >= 4     && < 5,-    reflection           >= 1.3.2 && < 2,+    reflection           >= 1.3.2 && < 3,     semigroups           >= 0.9   && < 1,     semigroupoids        >= 3     && < 6,     tagged               >= 0.4.4 && < 1,
src/Linear/V.hs view
@@ -41,6 +41,10 @@   , Dim(..)   , reifyDim   , reifyVector+#if MIN_VERSION_reflection(2,0,0)+  , reifyDimNat+  , reifyVectorNat+#endif   , fromVector   ) where @@ -126,6 +130,18 @@   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 #-}++reifyVectorNat :: forall a r. Vector a -> (forall (n :: Nat). KnownNat n => V n a -> r) -> r+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 i f = R.reify i (go f) where   go :: Reifies n Int => (Proxy (ReifiedDim n) -> a) -> proxy n -> a@@ -149,8 +165,42 @@   {-# INLINE imap #-}  instance Foldable (V n) where+  fold (V as) = fold as+  {-# INLINE fold #-}   foldMap f (V as) = foldMap f as   {-# INLINE foldMap #-}+  foldr f z (V as) = V.foldr f z as+  {-# INLINE foldr #-}+  foldl f z (V as) = V.foldl f z as+  {-# INLINE foldl #-}+  foldr' f z (V as) = V.foldr' f z as+  {-# INLINE foldr' #-}+  foldl' f z (V as) = V.foldl' f z as+  {-# INLINE foldl' #-}+  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+  {-# INLINE null #-}+  toList (V as) = V.toList as+  {-# INLINE toList #-}+  elem a (V as) = V.elem a as+  {-# INLINE elem #-}+  maximum (V as) = V.maximum as+  {-# INLINE maximum #-}+  minimum (V as) = V.minimum as+  {-# INLINE minimum #-}+  sum (V as) = V.sum as+  {-# INLINE sum #-}+  product (V as) = V.product as+  {-# INLINE product #-}+#endif+    instance FoldableWithIndex Int (V n) where   ifoldMap f (V as) = ifoldMap f as