Idris2Doc : Data.Array.Core

Data.Array.Core

(source)
Core data types and functions for working with immutable and
mutable (linear) arrays.

Definitions

prim__emptyArray : Integer->PrimIOAnyPtr
prim__newArray : Integer->AnyPtr->PrimIOAnyPtr
prim__arrayGet : AnyPtr->Integer->AnyPtr
prim__arraySet : AnyPtr->Integer->AnyPtr->PrimIO ()
prim__casSet : AnyPtr->Integer->a->a->Bits8
prim__copyArray : AnyPtr->Integer->Integer->AnyPtr->Integer->PrimIO ()
prim__bufToArr : Buffer->Integer->Integer->AnyPtr->Integer->PrimIO ()
prim__arrToBuf : AnyPtr->Integer->Integer->Buffer->Integer->PrimIO ()
prim__jsArrLength : AnyPtr->PrimIOBits32
recordIArray : Nat->Type->Type
  An immutable array of size `n` holding values of type `a`.

Totality: total
Visibility: export
Constructor: 
IA : AnyPtr->IArrayna

Projection: 
.arr : IArrayna->AnyPtr
at : IArrayna->Finn->a
  Safely access a value in an array at the given position.

Totality: total
Visibility: export
atByte : IArray256a->Bits8->a
  Safely use a byte as an index into an array.

Totality: total
Visibility: export
atOffset : IArrayna->Finm-> (off : Nat) -> {auto0_ : LTE (off+m) n} ->a
  Safely access a value in an array at the given position
and offset.

Totality: total
Visibility: export
take : (0m : Nat) ->IArrayna-> {auto0_ : LTEmn} ->IArrayma
  We can wrap a prefix of an array in O(1) simply by giving it
a new size index.

Note: If you only need a small portion of a potentially large
array the rest of which you no longer need, consider to
release the large array from memory by invoking `force`.

Totality: total
Visibility: export
unsafeToPtr : IArrayna->AnyPtr
  Extracts the wrapped `AnyPtr` value of an immutable array.

This can be used to pass the array in a foreign function call.
Client code is responsible to make sure the array is not
mutated in its raw form.

Totality: total
Visibility: export
dataMArray : Type->Nat->Type->Type
  A mutable array.

Totality: total
Visibility: export
Constructor: 
MA : AnyPtr->MArraysna
0IOArray : Nat->Type->Type
  Convenience alias for `MArray' RIO`.

Totality: total
Visibility: public export
unsafeMToPtr : MArraysna->AnyPtr
  Extracts the wrapped `AnyPtr` value of a mutable array.

This can be used to pass the array in a foreign function call.
Client code is responsible to make sure the array is not
mutated in its raw form.

Totality: total
Visibility: export
marray1 : (n : Nat) ->a->F1s (MArraysna)
  Fills a new mutable bound to linear computation `s`.

Totality: total
Visibility: export
marray : Lift1sf=> (n : Nat) ->a->f (MArraysna)
  Fills a new mutable array in `IO`.

Totality: total
Visibility: export
unsafeMArray1 : (n : Nat) ->F1s (MArraysna)
Totality: total
Visibility: export
unsafeMArray : Lift1sf=> (n : Nat) ->f (MArraysna)
  Allocates a new, empty, mutable array in `IO`.

Totality: total
Visibility: export
set : MArraysna->Finn->a->F1's
  Safely write a value to a mutable array.

Totality: total
Visibility: export
setBits8 : MArrays256a->Bits8->a->F1's
  Safely write a value to a mutable array.

Totality: total
Visibility: export
get : MArraysna->Finn->F1sa
  Safely read a value from a mutable array.

This returns the values thus read with unrestricted quantity, paired
with a new linear token of quantity one to be further used in the
linear context.

Totality: total
Visibility: export
getBits8 : MArrays256a->Bits8->F1sa
  Safely read a value from a mutable array.

This returns the values thus read with unrestricted quantity, paired
with a new linear token of quantity one to be further used in the
linear context.

Totality: total
Visibility: export
modify : MArraysna->Finn-> (a->a) ->F1's
  Safely modify a value in a mutable array.

Totality: total
Visibility: export
casset : MArraysna->Finn->a->a->F1sBool
  Atomically writes `val` at the given position of the mutable array
if its current value is equal to `pre`.

This is supported and has been tested on the Chez and Racket backends.
It trivially works on the JavaScript backends, which are single-threaded
anyway.

Totality: total
Visibility: export
casswap : MArraysna->Finn->a->F1's
  Atomically overwrites at the given position of the mutable array.

This is supported and has been tested on the Chez and Racket backends.
It trivially works on the JavaScript backends, which are single-threaded
anyway.

Totality: total
Visibility: export
casupdate : MArraysna->Finn-> (a-> (a, b)) ->F1sb
  Atomic modification of an array position using a CAS-loop internally.

This is supported and has been tested on the Chez and Racket backends.
It trivially works on the JavaScript backends, which are single-threaded
anyway.

Totality: total
Visibility: export
casmodify : MArraysna->Finn-> (a->a) ->F1's
  Atomic modification of an array position reference using a CAS-loop
internally.

This is supported and has been tested on the Chez and Racket backends.
It trivially works on the JavaScript backends, which are single-threaded
anyway.

Totality: total
Visibility: export
mtake : MArraysna-> (0m : Nat) -> {auto0_ : LTEmn} ->F1s (MArraysma)
  Wraps a mutable array in a shorter one.

Totality: total
Visibility: export
copy : MArraysma-> (srcOffset : Nat) -> (dstOffset : Nat) -> (len : Nat) -> {auto0_ : LTE (srcOffset+len) m} -> {auto0_ : LTE (dstOffset+len) n} ->MArraysna->F1's
Totality: total
Visibility: export
icopy : IArrayma-> (srcOffset : Nat) -> (dstOffset : Nat) -> (len : Nat) -> {auto0_ : LTE (srcOffset+len) m} -> {auto0_ : LTE (dstOffset+len) n} ->MArraysna->F1's
Totality: total
Visibility: export
copyToBuf : MArraysmBits8-> (srcOffset : Nat) -> (dstOffset : Nat) -> (len : Nat) -> {auto0_ : LTE (srcOffset+len) m} -> {auto0_ : LTE (dstOffset+len) n} ->MBuffersn->F1's
Totality: total
Visibility: export
icopyToBuf : IArraymBits8-> (srcOffset : Nat) -> (dstOffset : Nat) -> (len : Nat) -> {auto0_ : LTE (srcOffset+len) m} -> {auto0_ : LTE (dstOffset+len) n} ->MBuffersn->F1's
Totality: total
Visibility: export
copyToArray : MBuffersm-> (srcOffset : Nat) -> (dstOffset : Nat) -> (len : Nat) -> {auto0_ : LTE (srcOffset+len) m} -> {auto0_ : LTE (dstOffset+len) n} ->MArraysnBits8->F1's
Totality: total
Visibility: export
icopyToArray : IBufferm-> (srcOffset : Nat) -> (dstOffset : Nat) -> (len : Nat) -> {auto0_ : LTE (srcOffset+len) m} -> {auto0_ : LTE (dstOffset+len) n} ->MArraysnBits8->F1's
Totality: total
Visibility: export
thaw : IArrayna->F1s (MArraysna)
  Copy the content of an immutable array to a new mutable array.

Totality: total
Visibility: export
unsafeThaw : IArrayna->MArraysna
  Make the content of an immutable array accessible as a mutable array.

This is obviously unsafe. Don't use if you don't know exactly what you
are doing.

Totality: total
Visibility: export
0WithMArray : Nat->Type->Type->Type
Totality: total
Visibility: public export
alloc : (n : Nat) ->a->WithMArraynab->b
  Allocate and use a mutable array in a linear context.

Totality: total
Visibility: export
unsafeAlloc : (n : Nat) ->WithMArraynab->b
  Like `create` but the initially created array will not hold any
sensible data.

Use with care: Client code is responsible to properly initialize
the array with data. This is usefule for creating arrays of unknown
size, when it is not immediately clear, whether it will hold any
data at all.

See for instance the implementation of `filter` or `mapMaybe`.

Totality: total
Visibility: export
unsafeFreezeLTE : {auto0_ : LTEmn} ->MArraysna-> (0m : Nat) ->F1s (IArrayma)
  Wrap a mutable array in an immutable array, which can then be freely shared.

It is not possible the extract and share the underlying `ArrayData`
wrapped in an `IArray`, so we don't have to be afraid of shared mutable
state: The interface of `IArray` does not support to further mutate
the wrapped array.

It is safe to only use a prefix of a properly constructed array,
therefore we are free to give the resulting array a smaller size.
Most of the time, we'd like to use the whole array, in which case
we can just use `unsafeFreeze`.

Note: For reasons of efficiency, this does not copy the mutable array,
and therefore, it must no longer be modified after calling
this function.

Totality: total
Visibility: export
unsafeFreeze : MArraysna->F1s (IArrayna)
  Wrap a mutable array in an immutable array, which can then be freely shared.

Note: For reasons of efficiency, this does not copy the mutable array,
and therefore, it must no longer be modified after calling
this function.

Totality: total
Visibility: export
freezeLTE : MArraysna-> (m : Nat) -> {auto0_ : LTEmn} ->F1s (IArrayma)
  Copy a prefix of a mutable array into an immutable array.

Totality: total
Visibility: export
freeze : MArraysna->F1s (IArrayna)
  Copy a mutable buffer into an `IBuffer`.

Totality: total
Visibility: export
toIBuffer : IArraynBits8->IBuffern
  Copies an immutable array of bytes to a immutable buffer.

Totality: total
Visibility: export
toIArray : IBuffern->IArraynBits8
  Copies an immtuable buffer to an immutable array of bytes.

Totality: total
Visibility: export
unsafeJSMArrayOf1 : (0a : Type) ->AnyPtr->F1s (n : Nat**MArraysna)
  Utility for wrapping an array result from the FFI in a proper
Idris array.

Since we are wrapping a raw pointer, this is obviously an unsafe
operation and client code is responsible to make sure that the pointer
actually corresponds to a JS array or array-like.

Totality: total
Visibility: export
unsafeJSMArrayOf : HasIOio=> (0a : Type) ->AnyPtr->io (n : Nat**IOArrayna)
  Like `unsafeJSMArrayOf1` but runs in an `IO` monad.

Totality: total
Visibility: export