vector-sized 1.0.0.0 → 1.0.1.0
raw patch · 5 files changed
+22/−24 lines, 5 filesdep +adjunctionsdep +distributivedep ~indexed-list-literals
Dependencies added: adjunctions, distributive
Dependency ranges changed: indexed-list-literals
Files
- changelog.md +5/−0
- src/Data/Vector/Generic/Sized.hs +13/−6
- src/Data/Vector/Sized.hs +0/−6
- src/Data/Vector/Storable/Sized.hs +0/−6
- vector-sized.cabal +4/−6
changelog.md view
@@ -1,5 +1,10 @@ # Change Log +## [1.0.1.0] - 2018-04-12++- Add Representable and Distributive instances for sized boxed vectors+- Use newer version of indexed-list-literals to allow a fully featured compile on ghc 8.4+ ## [1.0.0.0] - 2018-03-20 - More functions using `Finite` instead of `Int`
src/Data/Vector/Generic/Sized.hs view
@@ -61,9 +61,7 @@ -- ** Initialization , empty , singleton-#if !MIN_VERSION_GLASGOW_HASKELL(8,3,0,0) , fromTuple-#endif , replicate , replicate' , generate@@ -266,6 +264,8 @@ import GHC.Read import Data.Type.Equality import Unsafe.Coerce+import qualified Data.Functor.Rep as Rep+import Data.Distributive import Prelude hiding (length, replicate, (++), head, last, init, tail, take, drop, splitAt, reverse, map, concatMap, zipWith, zipWith3, zip,@@ -274,10 +274,8 @@ scanr, scanr1, mapM, mapM_, sequence, sequence_) -#if !MIN_VERSION_GLASGOW_HASKELL(8,3,0,0) import Data.IndexedListLiterals hiding (toList) import qualified Data.IndexedListLiterals as ILL-#endif instance (KnownNat n, VG.Vector v a, Read (v a)) => Read (Vector v n a) where readPrec = parens $ prec 10 $ do@@ -326,6 +324,17 @@ mappend = zipWith mappend mconcat vs = generate $ mconcat . flip fmap vs . flip index +instance KnownNat n => Distributive (Vector Boxed.Vector n) where+ distribute = Rep.distributeRep+ {-# inline distribute #-}++instance KnownNat n => Rep.Representable (Vector Boxed.Vector n) where+ type Rep (Vector Boxed.Vector n) = Finite n+ tabulate = generate+ {-# inline tabulate #-}+ index = Data.Vector.Generic.Sized.index+ {-# inline index #-}+ -- | /O(1)/ Yield the length of the vector as an 'Int'. This is more like -- 'natVal' than 'Data.Vector.length', extracting the value from the 'KnownNat' -- instance and not looking at the vector itself.@@ -552,7 +561,6 @@ singleton a = Vector (VG.singleton a) {-# inline singleton #-} -#if !MIN_VERSION_GLASGOW_HASKELL(8,3,0,0) -- | /O(n)/ Construct a vector in a type safe manner -- fromTuple (1,2) :: Vector v 2 Int -- fromTuple ("hey", "what's", "going", "on") :: Vector v 4 String@@ -560,7 +568,6 @@ (VG.Vector v a, IndexedListLiterals input length a, KnownNat length) => input -> Vector v length a fromTuple = Vector . VG.fromListN (fromIntegral $ natVal $ Proxy @length) . ILL.toList-#endif -- | /O(n)/ Construct a vector with the same element in each position where the -- length is inferred from the type.
src/Data/Vector/Sized.hs view
@@ -54,9 +54,7 @@ -- ** Initialization , empty , singleton-#if !MIN_VERSION_GLASGOW_HASKELL(8,3,0,0) , fromTuple-#endif , replicate , replicate' , generate@@ -240,9 +238,7 @@ import GHC.TypeLits import Data.Finite import Data.Proxy-#if !MIN_VERSION_GLASGOW_HASKELL(8,3,0,0) import Data.IndexedListLiterals hiding (toList)-#endif import Control.Monad.Primitive import Prelude hiding ( length, null, replicate, (++), concat,@@ -472,7 +468,6 @@ singleton = V.singleton {-# inline singleton #-} -#if !MIN_VERSION_GLASGOW_HASKELL(8,3,0,0) -- | /O(n)/ Construct a vector in a type safe manner -- fromTuple (1,2) :: Vector 2 Int -- fromTuple ("hey", "what's", "going", "on") :: Vector 4 String@@ -480,7 +475,6 @@ (IndexedListLiterals input length ty, KnownNat length) => input -> Vector length ty fromTuple = V.fromTuple-#endif -- | /O(n)/ Construct a vector with the same element in each position where the -- length is inferred from the type.
src/Data/Vector/Storable/Sized.hs view
@@ -54,9 +54,7 @@ -- ** Initialization , empty , singleton-#if !MIN_VERSION_GLASGOW_HASKELL(8,3,0,0) , fromTuple-#endif , replicate , replicate' , generate@@ -236,9 +234,7 @@ import qualified Data.Vector.Generic.Sized as V import qualified Data.Vector.Storable as VS-#if !MIN_VERSION_GLASGOW_HASKELL(8,3,0,0) import Data.IndexedListLiterals (IndexedListLiterals)-#endif import qualified Data.Vector.Storable.Mutable.Sized as VSM import GHC.TypeLits import Data.Finite@@ -480,7 +476,6 @@ singleton = V.singleton {-# inline singleton #-} -#if !MIN_VERSION_GLASGOW_HASKELL(8,3,0,0) -- | /O(n)/ Construct a vector in a type safe manner -- fromTuple (1,2) :: Vector 2 Int -- fromTuple ("hey", "what's", "going", "on") :: Vector 4 String@@ -489,7 +484,6 @@ => input -> Vector length a fromTuple = V.fromTuple {-# inline fromTuple #-}-#endif -- | /O(n)/ Construct a vector with the same element in each position where the -- length is inferred from the type.
vector-sized.cabal view
@@ -1,5 +1,5 @@ name: vector-sized-version: 1.0.0.0+version: 1.0.1.0 synopsis: Size tagged vectors description: Please see README.md homepage: http://github.com/expipiplus1/vector-sized#readme@@ -14,9 +14,6 @@ , changelog.md cabal-version: >=1.10 --- nice literals are not enabled on GHC 8.4; see--- https://github.com/DavidM-D/indexed-list-literals/issues/1- library hs-source-dirs: src exposed-modules: Data.Vector.Sized@@ -32,8 +29,9 @@ , deepseq >= 1.1 && < 1.5 , finite-typelits >= 0.1 , primitive >= 0.5 && < 0.7- if impl(ghc < 8.3)- build-depends: indexed-list-literals >= 0.1.0.1+ , indexed-list-literals >= 0.2.0.0+ , adjunctions >= 4.3 && < 4.5+ , distributive >= 0.5 && < 0.6 default-language: Haskell2010 source-repository head