packages feed

sized-vector 1.4.1.0 → 1.4.2.0

raw patch · 3 files changed

+46/−28 lines, 3 filesdep ~deepseqdep ~singletonsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: deepseq, singletons

API changes (from Hackage documentation)

- Data.Vector.Sized: instance Monomorphicable Nat (Vector a)
+ Data.Vector.Sized: ifoldl :: (a -> Index n -> b -> a) -> a -> Vector b n -> a
+ Data.Vector.Sized: init :: Vector a (S n) -> Vector a n
+ Data.Vector.Sized: instance Monomorphicable (Vector a)
+ Data.Vector.Sized: instance Ord a => Ord (Vector a n)
- Data.Vector.Sized: append :: Vector a n -> Vector a m -> Vector a (n :+: m)
+ Data.Vector.Sized: append :: Vector a n -> Vector a m -> Vector a (n :+ m)
- Data.Vector.Sized: concat :: Vector (Vector a n) m -> Vector a (m :*: n)
+ Data.Vector.Sized: concat :: Vector (Vector a n) m -> Vector a (m :* n)

Files

Data/Vector/Sized.hs view
@@ -1,8 +1,7 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE DataKinds, GADTs, MultiParamTypeClasses, PolyKinds    #-}-{-# LANGUAGE ScopedTypeVariables, StandaloneDeriving, TypeFamilies #-}-{-# LANGUAGE TypeOperators, NoImplicitPrelude                      #-}+{-# LANGUAGE CPP, DataKinds, FlexibleContexts, FlexibleInstances, GADTs #-}+{-# LANGUAGE MultiParamTypeClasses, NoImplicitPrelude, PolyKinds        #-}+{-# LANGUAGE ScopedTypeVariables, StandaloneDeriving, TypeFamilies      #-}+{-# LANGUAGE TypeOperators                                              #-} -- | Size-parameterized vector types and functions. module Data.Vector.Sized ( -- * Vectors and indices                            Vector (..), Index,@@ -13,11 +12,11 @@                            -- ** List                            fromList, fromList', unsafeFromList, unsafeFromList', toList,                            -- * Basic functions-                           append, head, last, tail, null, length, sLength,+                           append, head, last, tail, init, null, length, sLength,                            -- * Vector transformations                            map, reverse, intersperse, transpose,                            -- * Reducing vectors (folds)-                           foldl, foldl', foldl1, foldl1', foldr, foldr1,+                           foldl, foldl', foldl1, foldl1', foldr, foldr1, ifoldl,                            -- ** Special folds                            concat, and, or, any, all, sum, product, maximum, minimum,                            -- * Subvectors@@ -35,19 +34,34 @@                            -- * Zipping vectors                            zip, zipSame, zipWith, zipWithSame, unzip                          ) where-import           Control.Applicative-import           Control.DeepSeq-import           Data.Hashable-import           Data.Maybe-import           Data.Type.Monomorphic-import           Data.Type.Natural     hiding (promote)-import           Data.Type.Ordinal+import           Control.Applicative   ((<$>))+import           Control.DeepSeq       (NFData (..))+import           Data.Hashable         (Hashable (..))+import           Data.Maybe            (Maybe (..), fromMaybe, listToMaybe)+import           Data.Singletons       (SingI, SingInstance (..), sing)+import           Data.Singletons       (singInstance)+import           Data.Type.Monomorphic (Monomorphic (..), Monomorphicable (..))+import           Data.Type.Natural     ((:*), (:+), (:-), (:-:), (:<<=), Min)+import           Data.Type.Natural     (Nat (..), One, SNat, Sing (..), Two)+import           Data.Type.Natural     (plusCommutative, plusSR, plusZR)+import           Data.Type.Natural     (sNatToInt, (%:*))+import           Data.Type.Ordinal     (Ordinal (..), ordToInt)+import           Prelude               (Bool (..), Eq (..), Int, Num (..))+import           Prelude               (Show (..), error, flip, fst, otherwise)+import           Prelude               (seq, snd, ($), (&&), (.), (||)) import qualified Prelude               as P-import           Prelude               (Eq(..), Bool(..), Int, Show(..), (&&), Num(..)-                                       , (||), not, error, ($), (.), seq, fst, snd-                                       , flip, otherwise)-import           Proof.Equational      hiding (promote)+import           Proof.Equational      (coerce, symmetry) +#if !(defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708)+import Data.Type.Natural (sS, sZ)+#else+sZ :: SNat Z+sZ = SZ++sS :: SNat n -> SNat (S n)+sS = SS+#endif+ -- | Fixed-length list. data Vector (a :: *) (n :: Nat)  where   Nil  :: Vector a Z@@ -68,6 +82,7 @@       Monomorphic vec -> Monomorphic $ x :- vec  deriving instance Show a => Show (Vector a n)+deriving instance P.Ord a => P.Ord (Vector a n) instance (Eq a) => Eq (Vector a n) where   Nil == Nil = True   (x :- xs) == (y :- ys) = x == y && xs == ys@@ -123,7 +138,7 @@ --------------------------------------------------  -- | Append two @Vector@s.-append :: Vector a n -> Vector a m -> Vector a (n :+: m)+append :: Vector a n -> Vector a m -> Vector a (n :+ m) append (x :- xs) ys = x :- append xs ys append Nil       ys = ys @@ -141,6 +156,7 @@ tail (_ :- xs) = xs  -- | Extract the elements before the last of a non-empty list.+-- Since 1.4.2.0 init :: Vector a (S n) -> Vector a n init (a :- as) =   case as of@@ -177,7 +193,7 @@     go :: Vector a m -> Vector a k -> Vector a (k :+ m)     go acc Nil = acc     go acc (x :- xs) = coerce (symmetry $ plusSR (sLength xs) (sLength acc)) $ go (x:- acc) xs-         + -- | The 'intersperse' function takes an element and a vector and -- \`intersperses\' that element between the elements of the vector. intersperse :: a -> Vector a n -> Vector a ((Two :* n) :- One)@@ -234,12 +250,12 @@ foldr1 f (x :- xs@(_ :- _)) = f x (foldr1 f xs)  -- | The function 'concat' concatenates all vectors in th vector.-concat :: Vector (Vector a n) m -> Vector a (m :*: n)+concat :: Vector (Vector a n) m -> Vector a (m :* n) concat Nil = Nil concat (xs :- xss) =   let n = sLength xs       n0 = sLength xss-  in coerce (symmetry $ plusCommutative (n0 %* n) n) $ xs `append` concat xss+  in coerce (symmetry $ plusCommutative (n0 %:* n) n) $ xs `append` concat xss  and, or :: Vector Bool m -> Bool -- | 'and' returns the conjunction of a Boolean vector.@@ -249,9 +265,9 @@ or  = foldr (||) False  any, all :: (a -> Bool) -> Vector a n -> Bool--- | Applied to a predicate and a list, 'any' determines if any element of the vector satisfies the predicate. +-- | Applied to a predicate and a list, 'any' determines if any element of the vector satisfies the predicate. any p = or . map p--- | Applied to a predicate and a list, 'all' determines if all element of the vector satisfies the predicate. +-- | Applied to a predicate and a list, 'all' determines if all element of the vector satisfies the predicate. all p = and . map p  sum, product :: P.Num a => Vector a n -> a@@ -439,5 +455,7 @@ ordinalVecs SZ      = Nil ordinalVecs (SS sn) = OZ :- map OS (ordinalVecs sn) +-- | Indexed version of 'foldl'.+-- Since 1.4.2.0 ifoldl :: (a -> Index n -> b -> a) -> a -> Vector b n -> a ifoldl fun a0 vs = foldl (\a (b, c) -> fun a b c) a0 $ zipSame (ordinalVecs $ sLength vs) vs
README.md view
@@ -1,5 +1,5 @@ Type-level sized vector library ================================-[![Build Status](https://travis-ci.org/konn/sized-vector.svg)](https://travis-ci.org/konn/sized-vector)+[![Build Status](https://travis-ci.org/konn/sized-vector.svg)](https://travis-ci.org/konn/sized-vector) [![Hackage](https://budueba.com/hackage/sized-vector)](https://hackage.haskell.org/package/sized-vector)  
sized-vector.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                sized-vector-version:             1.4.1.0+version:             1.4.2.0 synopsis:            Size-parameterized vector types and functions. description:         Size-parameterized vector types and functions using a data-type promotion. homepage:            https://github.com/konn/sized-vector@@ -27,11 +27,11 @@                ,       monomorphic              == 0.0.*                ,       equational-reasoning     >= 0.2          && < 0.3                ,       hashable                 >= 1.1          && < 1.3-               ,       deepseq                  == 1.3.*+               ,       deepseq                  >= 1.3          && < 1.5   if impl(ghc < 7.7)     build-depends:     singletons               == 0.8.*   if impl(ghc >= 7.7)-    build-depends:     singletons               == 1.0.*+    build-depends:     singletons               >= 1.0          && < 1.2  -- Benchmark coercion-bench --   buildable:            False