forbidden-fruit-0.1.0: A library accelerates imperative style programming.

Copyright(C) 2015, Yu Fukuzawa
LicenseBSD3
Maintainerminpou.primer@email.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Control.Imperative.Vector.Static

Contents

Description

 

Synopsis

Documentation

An efficient array which has two features.

  • Automatic switching unboxed and boxed arrays.
  • Multi-dimension support

There are two basic operation exported from the Control.Imperative module.

ref
O(1). return the element of a vector at the given index.
assign
O(1). replace the element at the given index.

Types

data Vector m n a Source

Instances

PrimMonad m => Indexable (Ref m (Vector m (S (S n)) a)) 
(VectorElem a, PrimMonad m) => Indexable (Ref m (Vector m (S Z) a)) 
Monad m => HasVector (Ref m (Vector m n a)) (Vector m n a) m 
PrimMonad m => Indexable (Vector m (S (S n)) a) 
(VectorElem a, PrimMonad m) => Indexable (Vector m (S Z) a) 
Monad m => HasVector (Vector m n a) (Vector m n a) m 
type Element (Ref m (Vector m (S (S n)) a)) = Ref m (Vector m (S n) a) 
type Element (Ref m (Vector m (S Z) a)) = Ref m a 
type IndexType (Ref m (Vector m (S (S n)) a)) = Int 
type IndexType (Ref m (Vector m (S Z) a)) = Int 
type Element (Vector m (S (S n)) a) = Ref m (Vector m (S n) a) 
type Element (Vector m (S Z) a) = Ref m a 
type IndexType (Vector m (S (S n)) a) = Int 
type IndexType (Vector m (S Z) a) = Int 

type MonadVector m = (MonadBase (BaseEff m) m, PrimMonad (BaseEff m)) Source

Useful constraint synonym for vector operations.

class Monad m => HasVector s v m | s -> v, s -> m Source

Minimal complete definition

getVector

Instances

Monad m => HasVector (Ref m (Vector m n a)) (Vector m n a) m 
Monad m => HasVector (Vector m n a) (Vector m n a) m 

type family NestedList n a Source

Equations

NestedList Z a = a 
NestedList (S n) a = [NestedList n a] 

data Size n where Source

A sized-list type for specify the size of array.

Constructors

One :: Size Z 
(:*:) :: !Int -> Size n -> Size (S n) infixr 5 

data Dim n Source

Specialized Proxy type.

Constructors

Dim 

dim2 :: Dim (S (S Z)) Source

dim3 :: Dim (S (S (S Z))) Source

Operations

newSized :: (VectorElem a, MonadVector m) => Size (S n) -> m (Vector (BaseEff m) (S n) a) Source

O(n). Create a vector of the given length.

newSized' :: (VectorElem a, MonadVector m) => Size (S n) -> a -> m (Vector (BaseEff m) (S n) a) Source

O(n). Create a vector filled with an initial value.

length :: (VectorElem a, HasVector s (Vector (BaseEff m) (S n) a) (BaseEff m), MonadVector m) => s -> m Int Source

O(1). The number of elements in the vector.

size :: (VectorElem a, HasVector s (Vector (BaseEff m) (S n) a) (BaseEff m), MonadVector m) => s -> m Int Source

Short alias for length.

fromListN Source

Arguments

:: (VectorElem a, MonadVector m) 
=> Size (S n)

sizes of vector

-> NestedList (S n) a

nested list

-> m (Vector (BaseEff m) (S n) a) 

O(n). Build a vector from a nested list.

toList :: (VectorElem a, HasVector s (Vector (BaseEff m) (S n) a) (BaseEff m), MonadVector m) => s -> m (NestedList (S n) a) Source

O(n). Convert the vector to a nested list.