fixed-vector 0.1 → 0.1.1
raw patch · 2 files changed
+47/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Vector.Fixed: Fun :: (Fn n a b) -> Fun n a b
+ Data.Vector.Fixed: convertContinuation :: Arity n => (forall v. (Dim v ~ n, Vector v a) => v a -> r) -> Fun n a r
+ Data.Vector.Fixed: foldM :: (Vector v a, Monad m) => (b -> a -> m b) -> b -> v a -> m b
+ Data.Vector.Fixed: newtype Fun n a b
+ Data.Vector.Fixed: tailWith :: (Arity n, Vector v a, Dim v ~ S n) => (forall w. (Vector w a, Dim w ~ n) => w a -> r) -> v a -> r
+ Data.Vector.Fixed: type N1 = S Z
+ Data.Vector.Fixed: type N2 = S N1
+ Data.Vector.Fixed: type N3 = S N2
+ Data.Vector.Fixed: type N4 = S N3
+ Data.Vector.Fixed: type N5 = S N4
+ Data.Vector.Fixed: type N6 = S N5
Files
- Data/Vector/Fixed.hs +41/−0
- fixed-vector.cabal +6/−1
Data/Vector/Fixed.hs view
@@ -17,10 +17,19 @@ Dim , Z , S+ -- ** Synonyms for small numerals+ , N1+ , N2+ , N3+ , N4+ , N5+ , N6 -- ** Type class , Vector(..) , Arity+ , Fun(..) , length+ , convertContinuation -- * Generic functions -- ** Literal vectors , New@@ -36,6 +45,7 @@ -- ** Element access , head , tail+ , tailWith , (!) -- ** Map , map@@ -44,6 +54,7 @@ -- ** Folding , foldl , foldl1+ , foldM , sum , maximum , minimum@@ -72,6 +83,23 @@ -- Generic functions ---------------------------------------------------------------- +type N1 = S Z+type N2 = S N1+type N3 = S N2+type N4 = S N3+type N5 = S N4+type N6 = S N5++-- | Change continuation type.+convertContinuation :: forall n a r. (Arity n)+ => (forall v. (Dim v ~ n, Vector v a) => v a -> r)+ -> Fun n a r+{-# INLINE convertContinuation #-}+convertContinuation f = fmap f g+ where+ g = construct :: Fun n a (VecList n a)++ -- TODO: does not fuse! -- | Newtype wrapper for partially constructed vectors. /n/ is number -- of uninitialized elements.@@ -206,6 +234,19 @@ {-# INLINE tailF #-} tailF (Fun f) = Fun (\_ -> f) +-- | Continuation variant of tail. It should be used when tail of+-- vector is immediately deconstructed with polymorphic+-- function. For example @'sum' . 'tail'@ will fail with unhelpful+-- error message because return value of @tail@ is polymorphic. But+-- @'tailWith' 'sum'@ works just fine.+tailWith :: (Arity n, Vector v a, Dim v ~ S n)+ => (forall w. (Vector w a, Dim w ~ n) => w a -> r) -- ^ Continuation+ -> v a -- ^ Vector+ -> r+{-# INLINE tailWith #-}+tailWith f v = inspectV v+ $ tailF+ $ convertContinuation f ----------------------------------------------------------------
fixed-vector.cabal view
@@ -1,5 +1,5 @@ Name: fixed-vector-Version: 0.1+Version: 0.1.1 Synopsis: Generic vectors with fixed length Description: Generic vectors with fixed length. Package is structured as follows:@@ -22,6 +22,11 @@ . [@Data.Vector.Fixed.Primitive@] Unboxed vectors based on pritimive package.+ .+ Changes in 0.1.1+ .+ * @foldM@ and @tailWith@ added. Type synonyms for numbers up to 6 are+ added. @Fun@ is reexported from @Data.Vector.Fixed@. Cabal-Version: >= 1.6 License: BSD3