hw-prim 0.1.0.0 → 0.1.0.1
raw patch · 5 files changed
+517/−412 lines, 5 filesdep ~base
Dependency ranges changed: base
Files
- README.md +1/−1
- hw-prim.cabal +3/−1
- src/HaskellWorks/Data/IndexedSeq.hs +134/−0
- src/HaskellWorks/Data/Seq.hs +368/−0
- src/HaskellWorks/Data/Vector/VectorLike.hs +11/−410
README.md view
@@ -1,5 +1,5 @@ # hw-prim-[](https://circleci.com/gh/haskell-works/hw-prim/tree/0.0-branch)+[](https://circleci.com/gh/haskell-works/hw-prim/tree/0-branch) Primitive types library.
hw-prim.cabal view
@@ -1,5 +1,5 @@ name: hw-prim-version: 0.1.0.0+version: 0.1.0.1 synopsis: Primitive functions and data types description: Please see README.md homepage: http://github.com/haskell-works/hw-prim#readme@@ -29,9 +29,11 @@ , HaskellWorks.Data.Decode , HaskellWorks.Data.FromByteString , HaskellWorks.Data.FromForeignRegion+ , HaskellWorks.Data.IndexedSeq , HaskellWorks.Data.Naive , HaskellWorks.Data.Positioning , HaskellWorks.Data.Search+ , HaskellWorks.Data.Seq , HaskellWorks.Data.TreeCursor , HaskellWorks.Data.Vector.BoxedVectorLike , HaskellWorks.Data.Vector.StorableVectorLike
+ src/HaskellWorks/Data/IndexedSeq.hs view
@@ -0,0 +1,134 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}++module HaskellWorks.Data.IndexedSeq+ ( IndexedSeq(..)+ , Seq(..)+ ) where++import qualified Data.ByteString as BS+import Data.Int+import qualified Data.Vector as DV+import qualified Data.Vector.Storable as DVS+import Data.Word+import HaskellWorks.Data.Positioning+import HaskellWorks.Data.Seq++class Seq v => IndexedSeq v where+ (!!!) :: v -> Position -> Elem v+ vIndex :: v -> Position -> Elem v++instance IndexedSeq String where+ (!!!) v (Position i) = v !! fromIntegral i+ vIndex v (Position i) = v !! fromIntegral i+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq BS.ByteString where+ (!!!) v (Position i) = v `BS.index` fromIntegral i+ vIndex v (Position i) = BS.index v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DV.Vector Word8) where+ (!!!) v (Position i) = v DV.! fromIntegral i+ vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DV.Vector Word16) where+ (!!!) v (Position i) = v DV.! fromIntegral i+ vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DV.Vector Word32) where+ (!!!) v (Position i) = v DV.! fromIntegral i+ vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DV.Vector Word64) where+ (!!!) v (Position i) = v DV.! fromIntegral i+ vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DVS.Vector Word8) where+ (!!!) v (Position i) = v DVS.! fromIntegral i+ vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DVS.Vector Word16) where+ (!!!) v (Position i) = v DVS.! fromIntegral i+ vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DVS.Vector Word32) where+ (!!!) v (Position i) = v DVS.! fromIntegral i+ vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DVS.Vector Word64) where+ (!!!) v (Position i) = v DVS.! fromIntegral i+ vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DV.Vector Int8) where+ (!!!) v (Position i) = v DV.! fromIntegral i+ vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DV.Vector Int16) where+ (!!!) v (Position i) = v DV.! fromIntegral i+ vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DV.Vector Int32) where+ (!!!) v (Position i) = v DV.! fromIntegral i+ vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DV.Vector Int64) where+ (!!!) v (Position i) = v DV.! fromIntegral i+ vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DVS.Vector Int8) where+ (!!!) v (Position i) = v DVS.! fromIntegral i+ vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DVS.Vector Int16) where+ (!!!) v (Position i) = v DVS.! fromIntegral i+ vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DVS.Vector Int32) where+ (!!!) v (Position i) = v DVS.! fromIntegral i+ vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DVS.Vector Int64) where+ (!!!) v (Position i) = v DVS.! fromIntegral i+ vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}++instance IndexedSeq (DVS.Vector Int) where+ (!!!) v (Position i) = v DVS.! fromIntegral i+ vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)+ {-# INLINE (!!!) #-}+ {-# INLINE vIndex #-}
+ src/HaskellWorks/Data/Seq.hs view
@@ -0,0 +1,368 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}++module HaskellWorks.Data.Seq+ ( Seq(..)+ ) where++import qualified Data.ByteString as BS+import Data.Int+import qualified Data.Vector as DV+import qualified Data.Vector.Storable as DVS+import Data.Word+import HaskellWorks.Data.Positioning++class Seq v where+ type Elem v+ vEmpty :: v+ vLength :: v -> Count+ vEnd :: v -> Position+ vEnd = fromIntegral . vLength+ vSnoc :: v -> Elem v -> v+ vDrop :: Count -> v -> v+ vTake :: Count -> v -> v+ vUncons :: v -> Maybe (Elem v, v)++instance Seq String where+ type Elem String = Char+ vEmpty = ""+ vLength = Count . fromIntegral . length+ vSnoc v c = v ++ [c]+ vDrop = drop . fromIntegral+ vTake = take . fromIntegral+ vUncons s = case s of+ (x:xs) -> Just (x, xs)+ _ -> Nothing++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq BS.ByteString where+ type Elem BS.ByteString = Word8++ vEmpty = BS.empty+ vLength = Count . fromIntegral . BS.length+ vSnoc = BS.snoc+ vDrop = BS.drop . fromIntegral+ vTake = BS.take . fromIntegral+ vUncons = BS.uncons++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DV.Vector Word8) where+ type Elem (DV.Vector Word8) = Word8++ vEmpty = DV.empty+ vLength = Count . fromIntegral . DV.length+ vSnoc = DV.snoc+ vDrop = DV.drop . fromIntegral+ vTake = DV.take . fromIntegral+ vUncons s = if DV.length s == 0 then Nothing else Just (DV.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DV.Vector Word16) where+ type Elem (DV.Vector Word16) = Word16++ vEmpty = DV.empty+ vLength = Count . fromIntegral . DV.length+ vSnoc = DV.snoc+ vDrop = DV.drop . fromIntegral+ vTake = DV.take . fromIntegral+ vUncons s = if DV.length s == 0 then Nothing else Just (DV.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DV.Vector Word32) where+ type Elem (DV.Vector Word32) = Word32++ vEmpty = DV.empty+ vLength = Count . fromIntegral . DV.length+ vSnoc = DV.snoc+ vDrop = DV.drop . fromIntegral+ vTake = DV.take . fromIntegral+ vUncons s = if DV.length s == 0 then Nothing else Just (DV.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DV.Vector Word64) where+ type Elem (DV.Vector Word64) = Word64++ vEmpty = DV.empty+ vLength = Count . fromIntegral . DV.length+ vSnoc = DV.snoc+ vDrop = DV.drop . fromIntegral+ vTake = DV.take . fromIntegral+ vUncons s = if DV.length s == 0 then Nothing else Just (DV.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DVS.Vector Word8) where+ type Elem (DVS.Vector Word8) = Word8++ vEmpty = DVS.empty+ vLength = Count . fromIntegral . DVS.length+ vSnoc = DVS.snoc+ vDrop = DVS.drop . fromIntegral+ vTake = DVS.take . fromIntegral+ vUncons s = if DVS.length s == 0 then Nothing else Just (DVS.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DVS.Vector Word16) where+ type Elem (DVS.Vector Word16) = Word16++ vEmpty = DVS.empty+ vLength = Count . fromIntegral . DVS.length+ vSnoc = DVS.snoc+ vDrop = DVS.drop . fromIntegral+ vTake = DVS.take . fromIntegral+ vUncons s = if DVS.length s == 0 then Nothing else Just (DVS.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DVS.Vector Word32) where+ type Elem (DVS.Vector Word32) = Word32++ vEmpty = DVS.empty+ vLength = Count . fromIntegral . DVS.length+ vSnoc = DVS.snoc+ vDrop = DVS.drop . fromIntegral+ vTake = DVS.take . fromIntegral+ vUncons s = if DVS.length s == 0 then Nothing else Just (DVS.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DVS.Vector Word64) where+ type Elem (DVS.Vector Word64) = Word64++ vEmpty = DVS.empty+ vLength = Count . fromIntegral . DVS.length+ vSnoc = DVS.snoc+ vDrop = DVS.drop . fromIntegral+ vTake = DVS.take . fromIntegral+ vUncons s = if DVS.length s == 0 then Nothing else Just (DVS.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DV.Vector Int8) where+ type Elem (DV.Vector Int8) = Int8++ vEmpty = DV.empty+ vLength = Count . fromIntegral . DV.length+ vSnoc = DV.snoc+ vDrop = DV.drop . fromIntegral+ vTake = DV.take . fromIntegral+ vUncons s = if DV.length s == 0 then Nothing else Just (DV.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DV.Vector Int16) where+ type Elem (DV.Vector Int16) = Int16++ vEmpty = DV.empty+ vLength = Count . fromIntegral . DV.length+ vSnoc = DV.snoc+ vDrop = DV.drop . fromIntegral+ vTake = DV.take . fromIntegral+ vUncons s = if DV.length s == 0 then Nothing else Just (DV.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DV.Vector Int32) where+ type Elem (DV.Vector Int32) = Int32++ vEmpty = DV.empty+ vLength = Count . fromIntegral . DV.length+ vSnoc = DV.snoc+ vDrop = DV.drop . fromIntegral+ vTake = DV.take . fromIntegral+ vUncons s = if DV.length s == 0 then Nothing else Just (DV.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DV.Vector Int64) where+ type Elem (DV.Vector Int64) = Int64++ vEmpty = DV.empty+ vLength = Count . fromIntegral . DV.length+ vSnoc = DV.snoc+ vDrop = DV.drop . fromIntegral+ vTake = DV.take . fromIntegral+ vUncons s = if DV.length s == 0 then Nothing else Just (DV.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DVS.Vector Int8) where+ type Elem (DVS.Vector Int8) = Int8++ vEmpty = DVS.empty+ vLength = Count . fromIntegral . DVS.length+ vSnoc = DVS.snoc+ vDrop = DVS.drop . fromIntegral+ vTake = DVS.take . fromIntegral+ vUncons s = if DVS.length s == 0 then Nothing else Just (DVS.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DVS.Vector Int16) where+ type Elem (DVS.Vector Int16) = Int16++ vEmpty = DVS.empty+ vLength = Count . fromIntegral . DVS.length+ vSnoc = DVS.snoc+ vDrop = DVS.drop . fromIntegral+ vTake = DVS.take . fromIntegral+ vUncons s = if DVS.length s == 0 then Nothing else Just (DVS.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DVS.Vector Int32) where+ type Elem (DVS.Vector Int32) = Int32++ vEmpty = DVS.empty+ vLength = Count . fromIntegral . DVS.length+ vSnoc = DVS.snoc+ vDrop = DVS.drop . fromIntegral+ vTake = DVS.take . fromIntegral+ vUncons s = if DVS.length s == 0 then Nothing else Just (DVS.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DVS.Vector Int64) where+ type Elem (DVS.Vector Int64) = Int64++ vEmpty = DVS.empty+ vLength = Count . fromIntegral . DVS.length+ vSnoc = DVS.snoc+ vDrop = DVS.drop . fromIntegral+ vTake = DVS.take . fromIntegral+ vUncons s = if DVS.length s == 0 then Nothing else Just (DVS.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}++instance Seq (DVS.Vector Int) where+ type Elem (DVS.Vector Int) = Int++ vEmpty = DVS.empty+ vLength = Count . fromIntegral . DVS.length+ vSnoc = DVS.snoc+ vDrop = DVS.drop . fromIntegral+ vTake = DVS.take . fromIntegral+ vUncons s = if DVS.length s == 0 then Nothing else Just (DVS.head s, vDrop 1 s)++ {-# INLINE vEmpty #-}+ {-# INLINE vLength #-}+ {-# INLINE vEnd #-}+ {-# INLINE vSnoc #-}+ {-# INLINE vDrop #-}+ {-# INLINE vTake #-}+ {-# INLINE vUncons #-}
src/HaskellWorks/Data/Vector/VectorLike.hs view
@@ -4,6 +4,8 @@ module HaskellWorks.Data.Vector.VectorLike ( VectorLike(..)+ , IndexedSeq(..)+ , Seq(..) ) where import qualified Data.ByteString as BS@@ -11,564 +13,163 @@ import qualified Data.Vector as DV import qualified Data.Vector.Storable as DVS import Data.Word-import HaskellWorks.Data.Positioning+import HaskellWorks.Data.IndexedSeq -- | Class of values that support vector like operations-class VectorLike v where- type Elem v- (!!!) :: v -> Position -> Elem v+class IndexedSeq v => VectorLike v where vConcat :: [v] -> v- vEmpty :: v vFilter :: (Elem v -> Bool) -> v -> v vGenerate :: Int -> (Int -> Elem v) -> v- vLength :: v -> Count- vEnd :: v -> Position- vEnd = fromIntegral . vLength- vSnoc :: v -> Elem v -> v- vDrop :: Count -> v -> v- vTake :: Count -> v -> v- vIndex :: v -> Position -> Elem v- vSlice :: Position -> Position -> v -> v- vUncons :: v -> Maybe (Elem v, v) instance VectorLike String where- type Elem String = Char- (!!!) v (Position i) = v !! fromIntegral i vConcat = concat- vEmpty = "" vFilter = filter vGenerate n f = f `fmap` [0 .. (n - 1)]- vLength = Count . fromIntegral . length- vEnd = Position . fromIntegral . length- vSnoc v c = v ++ [c]- vDrop = drop . fromIntegral- vTake = take . fromIntegral- vIndex v (Position i) = v !! fromIntegral i- vSlice (Position i) (Position j) = take (fromIntegral j) . drop (fromIntegral i)- vUncons s = case s of- (x:xs) -> Just (x, xs)- _ -> Nothing- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike BS.ByteString where- type Elem BS.ByteString = Word8-- (!!!) v (Position i) = v `BS.index` fromIntegral i vConcat = BS.concat- vEmpty = BS.empty vFilter = BS.filter vGenerate n f = fst (BS.unfoldrN n go 0) where go i = if i /= n then Just (f i, i + 1) else Nothing- vLength = Count . fromIntegral . BS.length- vEnd = Position . fromIntegral . BS.length- vSnoc = BS.snoc- vDrop = BS.drop . fromIntegral- vTake = BS.take . fromIntegral- vIndex v (Position i) = BS.index v (fromIntegral i)- vSlice (Position i) (Position j) = BS.take (fromIntegral j) . BS.drop (fromIntegral i)- vUncons = BS.uncons- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DV.Vector Word8) where- type Elem (DV.Vector Word8) = Word8-- (!!!) v (Position i) = v DV.! fromIntegral i vConcat = DV.concat- vEmpty = DV.empty vFilter = DV.filter vGenerate = DV.generate- vLength = Count . fromIntegral . DV.length- vEnd = Position . fromIntegral . DV.length- vSnoc = DV.snoc- vDrop = DV.drop . fromIntegral- vTake = DV.take . fromIntegral- vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DV.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DV.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DV.Vector Word16) where- type Elem (DV.Vector Word16) = Word16-- (!!!) v (Position i) = v DV.! fromIntegral i vConcat = DV.concat- vEmpty = DV.empty vFilter = DV.filter vGenerate = DV.generate- vLength = Count . fromIntegral . DV.length- vEnd = Position . fromIntegral . DV.length- vSnoc = DV.snoc- vDrop = DV.drop . fromIntegral- vTake = DV.take . fromIntegral- vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DV.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DV.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DV.Vector Word32) where- type Elem (DV.Vector Word32) = Word32-- (!!!) v (Position i) = v DV.! fromIntegral i vConcat = DV.concat- vEmpty = DV.empty vFilter = DV.filter vGenerate = DV.generate- vLength = Count . fromIntegral . DV.length- vEnd = Position . fromIntegral . DV.length- vSnoc = DV.snoc- vDrop = DV.drop . fromIntegral- vTake = DV.take . fromIntegral- vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DV.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DV.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DV.Vector Word64) where- type Elem (DV.Vector Word64) = Word64-- (!!!) v (Position i) = v DV.! fromIntegral i vConcat = DV.concat- vEmpty = DV.empty vFilter = DV.filter vGenerate = DV.generate- vLength = Count . fromIntegral . DV.length- vEnd = Position . fromIntegral . DV.length- vSnoc = DV.snoc- vDrop = DV.drop . fromIntegral- vTake = DV.take . fromIntegral- vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DV.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DV.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DVS.Vector Word8) where- type Elem (DVS.Vector Word8) = Word8-- (!!!) v (Position i) = v DVS.! fromIntegral i vConcat = DVS.concat- vEmpty = DVS.empty vFilter = DVS.filter vGenerate = DVS.generate- vLength = Count . fromIntegral . DVS.length- vEnd = Position . fromIntegral . DVS.length- vSnoc = DVS.snoc- vDrop = DVS.drop . fromIntegral- vTake = DVS.take . fromIntegral- vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DVS.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DVS.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DVS.Vector Word16) where- type Elem (DVS.Vector Word16) = Word16-- (!!!) v (Position i) = v DVS.! fromIntegral i vConcat = DVS.concat- vEmpty = DVS.empty vFilter = DVS.filter vGenerate = DVS.generate- vLength = Count . fromIntegral . DVS.length- vEnd = Position . fromIntegral . DVS.length- vSnoc = DVS.snoc- vDrop = DVS.drop . fromIntegral- vTake = DVS.take . fromIntegral- vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DVS.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DVS.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DVS.Vector Word32) where- type Elem (DVS.Vector Word32) = Word32-- (!!!) v (Position i) = v DVS.! fromIntegral i vConcat = DVS.concat- vEmpty = DVS.empty vFilter = DVS.filter vGenerate = DVS.generate- vLength = Count . fromIntegral . DVS.length- vEnd = Position . fromIntegral . DVS.length- vSnoc = DVS.snoc- vDrop = DVS.drop . fromIntegral- vTake = DVS.take . fromIntegral- vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DVS.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DVS.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DVS.Vector Word64) where- type Elem (DVS.Vector Word64) = Word64-- (!!!) v (Position i) = v DVS.! fromIntegral i vConcat = DVS.concat- vEmpty = DVS.empty vFilter = DVS.filter vGenerate = DVS.generate- vLength = Count . fromIntegral . DVS.length- vEnd = Position . fromIntegral . DVS.length- vSnoc = DVS.snoc- vDrop = DVS.drop . fromIntegral- vTake = DVS.take . fromIntegral- vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DVS.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DVS.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DV.Vector Int8) where- type Elem (DV.Vector Int8) = Int8-- (!!!) v (Position i) = v DV.! fromIntegral i vConcat = DV.concat- vEmpty = DV.empty vFilter = DV.filter vGenerate = DV.generate- vLength = Count . fromIntegral . DV.length- vEnd = Position . fromIntegral . DV.length- vSnoc = DV.snoc- vDrop = DV.drop . fromIntegral- vTake = DV.take . fromIntegral- vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DV.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DV.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DV.Vector Int16) where- type Elem (DV.Vector Int16) = Int16-- (!!!) v (Position i) = v DV.! fromIntegral i vConcat = DV.concat- vEmpty = DV.empty vFilter = DV.filter vGenerate = DV.generate- vLength = Count . fromIntegral . DV.length- vEnd = Position . fromIntegral . DV.length- vSnoc = DV.snoc- vDrop = DV.drop . fromIntegral- vTake = DV.take . fromIntegral- vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DV.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DV.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DV.Vector Int32) where- type Elem (DV.Vector Int32) = Int32-- (!!!) v (Position i) = v DV.! fromIntegral i vConcat = DV.concat- vEmpty = DV.empty vFilter = DV.filter vGenerate = DV.generate- vLength = Count . fromIntegral . DV.length- vEnd = Position . fromIntegral . DV.length- vSnoc = DV.snoc- vDrop = DV.drop . fromIntegral- vTake = DV.take . fromIntegral- vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DV.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DV.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DV.Vector Int64) where- type Elem (DV.Vector Int64) = Int64-- (!!!) v (Position i) = v DV.! fromIntegral i vConcat = DV.concat- vEmpty = DV.empty vFilter = DV.filter vGenerate = DV.generate- vLength = Count . fromIntegral . DV.length- vEnd = Position . fromIntegral . DV.length- vSnoc = DV.snoc- vDrop = DV.drop . fromIntegral- vTake = DV.take . fromIntegral- vIndex v (Position i) = DV.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DV.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DV.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DVS.Vector Int8) where- type Elem (DVS.Vector Int8) = Int8-- (!!!) v (Position i) = v DVS.! fromIntegral i vConcat = DVS.concat- vEmpty = DVS.empty vFilter = DVS.filter vGenerate = DVS.generate- vLength = Count . fromIntegral . DVS.length- vEnd = Position . fromIntegral . DVS.length- vSnoc = DVS.snoc- vDrop = DVS.drop . fromIntegral- vTake = DVS.take . fromIntegral- vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DVS.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DVS.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DVS.Vector Int16) where- type Elem (DVS.Vector Int16) = Int16-- (!!!) v (Position i) = v DVS.! fromIntegral i vConcat = DVS.concat- vEmpty = DVS.empty vFilter = DVS.filter vGenerate = DVS.generate- vLength = Count . fromIntegral . DVS.length- vEnd = Position . fromIntegral . DVS.length- vSnoc = DVS.snoc- vDrop = DVS.drop . fromIntegral- vTake = DVS.take . fromIntegral- vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DVS.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DVS.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DVS.Vector Int32) where- type Elem (DVS.Vector Int32) = Int32-- (!!!) v (Position i) = v DVS.! fromIntegral i vConcat = DVS.concat- vEmpty = DVS.empty vFilter = DVS.filter vGenerate = DVS.generate- vLength = Count . fromIntegral . DVS.length- vEnd = Position . fromIntegral . DVS.length- vSnoc = DVS.snoc- vDrop = DVS.drop . fromIntegral- vTake = DVS.take . fromIntegral- vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DVS.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DVS.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-} instance VectorLike (DVS.Vector Int64) where- type Elem (DVS.Vector Int64) = Int64+ vConcat = DVS.concat+ vFilter = DVS.filter+ vGenerate = DVS.generate+ {-# INLINE vConcat #-}+ {-# INLINE vFilter #-}+ {-# INLINE vGenerate #-} - (!!!) v (Position i) = v DVS.! fromIntegral i+instance VectorLike (DVS.Vector Int) where vConcat = DVS.concat- vEmpty = DVS.empty vFilter = DVS.filter vGenerate = DVS.generate- vLength = Count . fromIntegral . DVS.length- vEnd = Position . fromIntegral . DVS.length- vSnoc = DVS.snoc- vDrop = DVS.drop . fromIntegral- vTake = DVS.take . fromIntegral- vIndex v (Position i) = DVS.unsafeIndex v (fromIntegral i)- vSlice (Position i) (Position j) = DVS.unsafeSlice (fromIntegral i) (fromIntegral j)- vUncons s = if DVS.length s == 0 then Nothing else Just (s !!! 0, vDrop 1 s)- {-# INLINE (!!!) #-} {-# INLINE vConcat #-}- {-# INLINE vEmpty #-} {-# INLINE vFilter #-} {-# INLINE vGenerate #-}- {-# INLINE vLength #-}- {-# INLINE vEnd #-}- {-# INLINE vSnoc #-}- {-# INLINE vDrop #-}- {-# INLINE vTake #-}- {-# INLINE vIndex #-}- {-# INLINE vSlice #-}- {-# INLINE vUncons #-}