Copyright | (c) Roman Leshchinskiy 2008-2010 Alexey Kuleshevich 2020-2022 Aleksey Khudyakov 2020-2022 Andrew Lelechenko 2020-2022 |
---|---|
License | BSD-style |
Maintainer | Haskell Libraries Team <libraries@haskell.org> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Purely functional interface to initialisation of mutable vectors
Synopsis
- data New (v :: Type -> Type) a = New (forall s. ST s (Mutable v s a))
- create :: forall (v :: Type -> Type) a. (forall s. ST s (Mutable v s a)) -> New v a
- run :: forall (v :: Type -> Type) a s. New v a -> ST s (Mutable v s a)
- runPrim :: forall m (v :: Type -> Type) a. PrimMonad m => New v a -> m (Mutable v (PrimState m) a)
- apply :: forall (v :: Type -> Type) a. (forall s. Mutable v s a -> Mutable v s a) -> New v a -> New v a
- modify :: forall (v :: Type -> Type) a. (forall s. Mutable v s a -> ST s ()) -> New v a -> New v a
- modifyWithBundle :: forall (v :: Type -> Type) a (u :: Type -> Type) b. (forall s. Mutable v s a -> Bundle u b -> ST s ()) -> New v a -> Bundle u b -> New v a
- unstream :: forall (v :: Type -> Type) a. Vector v a => Bundle v a -> New v a
- transform :: forall (v :: Type -> Type) a. Vector v a => (forall (m :: Type -> Type). Monad m => Stream m a -> Stream m a) -> (Size -> Size) -> New v a -> New v a
- unstreamR :: forall (v :: Type -> Type) a. Vector v a => Bundle v a -> New v a
- transformR :: forall (v :: Type -> Type) a. Vector v a => (forall (m :: Type -> Type). Monad m => Stream m a -> Stream m a) -> (Size -> Size) -> New v a -> New v a
- slice :: forall (v :: Type -> Type) a. Vector v a => Int -> Int -> New v a -> New v a
- init :: forall (v :: Type -> Type) a. Vector v a => New v a -> New v a
- tail :: forall (v :: Type -> Type) a. Vector v a => New v a -> New v a
- take :: forall (v :: Type -> Type) a. Vector v a => Int -> New v a -> New v a
- drop :: forall (v :: Type -> Type) a. Vector v a => Int -> New v a -> New v a
- unsafeSlice :: forall (v :: Type -> Type) a. Vector v a => Int -> Int -> New v a -> New v a
- unsafeInit :: forall (v :: Type -> Type) a. Vector v a => New v a -> New v a
- unsafeTail :: forall (v :: Type -> Type) a. Vector v a => New v a -> New v a
Array recycling primitives
data New (v :: Type -> Type) a Source #
This data type is a wrapper around a monadic action which produces a mutable vector. It's used by a number of rewrite rules in order to facilitate the reuse of buffers allocated for vectors. See "Recycle your arrays!" for a detailed explanation.
Note that this data type must be declared as data
and not newtype
since it's used for rewrite rules and rules won't fire with newtype
.
runPrim :: forall m (v :: Type -> Type) a. PrimMonad m => New v a -> m (Mutable v (PrimState m) a) Source #
apply :: forall (v :: Type -> Type) a. (forall s. Mutable v s a -> Mutable v s a) -> New v a -> New v a Source #
modify :: forall (v :: Type -> Type) a. (forall s. Mutable v s a -> ST s ()) -> New v a -> New v a Source #
modifyWithBundle :: forall (v :: Type -> Type) a (u :: Type -> Type) b. (forall s. Mutable v s a -> Bundle u b -> ST s ()) -> New v a -> Bundle u b -> New v a Source #
transform :: forall (v :: Type -> Type) a. Vector v a => (forall (m :: Type -> Type). Monad m => Stream m a -> Stream m a) -> (Size -> Size) -> New v a -> New v a Source #
transformR :: forall (v :: Type -> Type) a. Vector v a => (forall (m :: Type -> Type). Monad m => Stream m a -> Stream m a) -> (Size -> Size) -> New v a -> New v a Source #
unsafeSlice :: forall (v :: Type -> Type) a. Vector v a => Int -> Int -> New v a -> New v a Source #
References
- Leshchinskiy, Roman. "Recycle your arrays!". Practical Aspects of Declarative Languages: 11th International Symposium, PADL 2009, Savannah, GA, USA, January 19-20, 2009. Proceedings 11. Springer Berlin Heidelberg, 2009.