{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
module Data.Vector.Storable.Sized
( Vector
, fromVector
, replicate
, singleton
, generate
, length
, index
, head
, last
, tail
, init
, take
, drop
, map
, foldl'
, foldl1'
) where
import qualified Data.Vector.Generic.Sized as VGS
import qualified Data.Vector.Storable as VS
import GHC.TypeLits
import Data.Proxy
import Foreign.Storable
import Prelude hiding (replicate, head, last,
tail, init, map, length, drop, take)
type Vector = VGS.Vector VS.Vector
fromVector :: forall a (n :: Nat). (KnownNat n, Storable a)
=> VS.Vector a -> Maybe (Vector n a)
fromVector = VGS.fromVector
{-# INLINE fromVector #-}
singleton :: forall a. Storable a
=> a -> Vector 1 a
singleton = VGS.singleton
{-# INLINE singleton #-}
generate :: forall (n :: Nat) a. (Storable a, KnownNat n)
=> Proxy n -> (Int -> a) -> Vector n a
generate = VGS.generate
{-# INLINE generate #-}
index :: forall (m :: Nat) a (n :: Nat). (KnownNat n, KnownNat m, Storable a)
=> Vector (m+n) a -> Proxy n -> a
index = VGS.index
{-# INLINE index #-}
take :: forall (m :: Nat) a (n :: Nat). (KnownNat n, KnownNat m, Storable a)
=> Proxy n -> Vector (m+n) a -> Vector n a
take = VGS.take
{-# INLINE take #-}
drop :: forall (m :: Nat) a (n :: Nat). (KnownNat n, KnownNat m, Storable a)
=> Proxy n -> Vector (m+n) a -> Vector m a
drop = VGS.drop
{-# INLINE drop #-}
length :: forall a (n :: Nat). (Storable a)
=> Vector n a -> Int
length = VGS.length
{-# INLINE length #-}
head :: forall a (n :: Nat). (Storable a)
=> Vector (n+1) a -> a
head = VGS.head
{-# INLINE head #-}
last :: forall a (n :: Nat). (Storable a)
=> Vector (n+1) a -> a
last = VGS.last
{-# INLINE last #-}
tail :: forall a (n :: Nat). (Storable a)
=> Vector (n+1) a -> Vector n a
tail = VGS.tail
{-# INLINE tail #-}
init :: forall a (n :: Nat). (Storable a)
=> Vector (n+1) a -> Vector n a
init = VGS.init
{-# INLINE init #-}
replicate :: forall a (n :: Nat). (Storable a, KnownNat n)
=> a -> Vector n a
replicate = VGS.replicate
{-# INLINE replicate #-}
map :: forall a b (n :: Nat). (Storable a, Storable b)
=> (a -> b) -> Vector n a -> Vector n b
map = VGS.map
{-# INLINE map #-}
foldl' :: forall a b (n :: Nat). Storable b
=> (a -> b -> a) -> a -> Vector n b -> a
foldl' = VGS.foldl'
{-# INLINE foldl' #-}
foldl1' :: forall a (n :: Nat). Storable a
=> (a -> a -> a) -> Vector (n+1) a -> a
foldl1' = VGS.foldl1'
{-# INLINE foldl1' #-}