Idris2Doc : Data.C.Array

Data.C.Array

(source)

Reexports

importpublic Data.Fin
importpublic Data.Linear.Token
importpublic Data.Array.Index
importpublic Data.C.Struct

Definitions

prim__copy_pp : AnyPtr->AnyPtr->Bits32->PrimIO ()
prim__copy_pb : AnyPtr->Buffer->Bits32->PrimIO ()
prim__copy_bp : Buffer->AnyPtr->Bits32->PrimIO ()
prim__inc_ptr : AnyPtr->Bits32->Bits32->AnyPtr
prim__scrub : AnyPtr->Bits32->PrimIO ()
recordCIArray : Nat->Type->Type
  A wrapped pointer to a C-array holding `n` values of (C-primitive)
type `a`.

Reading from such an array is O(1) and can be done in pure functions.

See `CArrayIO` for a version of mutable C arrays running in `IO`.
See `CArray` for an mutable wrapper to be used in pure (linear) code.

Note : In general, this type is not for prolonged storage in an Idris data
structure (although this is still possible), because it needs to be
eventually freed. A typical use case is to make use of this for
its pure and clean API, but to do so from within `IO` or `F1` by
using `withIArray`.

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

Projection: 
.ptr : CIArrayna->AnyPtr
at : SizeOfa=>Derefa=>CIArrayna->Finn->a
Totality: total
Visibility: export
ix : SizeOfa=>Derefa=>CIArrayna-> (0m : Nat) ->Ix (Sm) n=>a
Totality: total
Visibility: export
atNat : SizeOfa=>Derefa=>CIArrayna-> (m : Nat) -> {auto0_ : LTmn} ->a
Totality: total
Visibility: export
toVect : SizeOfa=>Derefa=>CIArrayna->Vectna
  Reads the values from a C pointer into a vector.

Totality: total
Visibility: export
foldrKV : SizeOfa=>Derefa=> (Finn->a->b->b) ->b->CIArrayna->b
  Right fold over the values of an array plus their indices.

Totality: total
Visibility: export
foldr : SizeOfa=>Derefa=> (a->b->b) ->b->CIArrayna->b
  Right fold over the values of an array

Totality: total
Visibility: export
foldlKV : SizeOfa=>Derefa=> (Finn->b->a->b) ->b->CIArrayna->b
  Left fold over the values of an array plus their indices.

Totality: total
Visibility: export
foldl : SizeOfa=>Derefa=> (b->a->b) ->b->CIArrayna->b
  Left fold over the values of an array

Totality: total
Visibility: export
withPtr : HasIOio=>Bits32-> (AnyPtr->ioa) ->ioa
  Allocates a pointer of the given size and uses it for running
the given computation. The pointer is freed afterwards.

Totality: total
Visibility: export
recordPrimCArray : Type->Bool->Nat->Type->Type
  A wrapped pointer to a C-array holding `n` values of (C-primitive)
type `a`.

Reading from and writing to such an array is O(1) and runs in `IO`.

See `CArray` for a pure version of mutable C arrays using linear types.
See `CArrayS` for a pure versoin of mutable C arrays using linear types (overwritting/scrubbing before freeing).
See `CArrayIO` for a version of mutable C arrays usable in IO.
See `CArrayIOS` for a version of the mutable C arrays usuable in IO (overwritting/scrubbing before freeing)

Note : In typical use cases, the memory allocated for a C array must
be manually released with a call to `free` unless it is part
of a larger structure `Struct` or managed by an external library.

Totality: total
Visibility: export
Constructor: 
PCA : AnyPtr->PrimCArraysbna

Projection: 
.ptr : PrimCArraysbna->AnyPtr
0CArray : Type->Nat->Type->Type
  Convenience alias for `PrimCArray s False n a`

Totality: total
Visibility: public export
0CArrayS : Type->Nat->Type->Type
  Convenience alias for `PrimCArray s True n a`

Totality: total
Visibility: public export
0CArrayIO : Nat->Type->Type
  Convenience alias for `PrimCArray World False n a`

Totality: total
Visibility: public export
0CArrayIOS : Nat->Type->Type
  Convenience alias for `PrimCArray World True n a`

Totality: total
Visibility: public export
unsafeUnwrap : CArraysna->AnyPtr
Totality: total
Visibility: export
unsafeWrap : AnyPtr->CArraysna
Totality: total
Visibility: export
0IOBox : Type->Type
Totality: total
Visibility: public export
0Box : Type->Type->Type
Totality: total
Visibility: public export
malloc1 : (0a : Type) ->SizeOfa=> (n : Nat) ->F1s (CArraysna)
  Allocates a new C-pointer of `sizeof a * n` bytes.

Totality: total
Visibility: export
calloc1 : (0a : Type) ->SizeOfa=> (n : Nat) ->F1s (CArraysna)
  Like `malloc1` but resets all allocated bytes to zero.

Totality: total
Visibility: export
free1 : CArraysna->F1's
  Frees the memory allocated for a C pointer and removes it from the
resources bound to the linear token.

Totality: total
Visibility: export
frees1 : SizeOfa=>CArraySsna->F1's
  Frees the memory allocated for a C pointer, after overwriting the data,
and removes it from the resources bound to the linear token.

Totality: total
Visibility: export
unbox : Derefa=>CArrays (Sn) a->F1sa
  Extracts the first value stored in a C pointer.

Totality: total
Visibility: export
getStruct : Structf=>SizeOf (fs) =>CArraysn (fs) ->Finn->F1s (fs)
  Reads a struct from a C-pointer at the given position.

Totality: total
Visibility: export
getStructIx : Structf=>SizeOf (fs) =>CArraysn (fs) -> (0m : Nat) ->Ix (Sm) n=>F1s (fs)
  Reads a struct from a C-pointer at the given position.

Totality: total
Visibility: export
getStructNat : Structf=>SizeOf (fs) =>CArraysn (fs) -> (m : Nat) -> {auto0_ : LTmn} ->F1s (fs)
  Reads a struct from a C-pointer at the given position.

Totality: total
Visibility: export
get : SizeOfa=>CArraysna->Derefa=>Finn->F1sa
  Reads a value from a C-pointer at the given position.

Totality: total
Visibility: export
getIx : SizeOfa=>CArraysna->Derefa=> (0m : Nat) ->Ix (Sm) n=>F1sa
  Reads a value from a C-pointer at the given position.

Totality: total
Visibility: export
getNat : SizeOfa=>CArraysna->Derefa=> (m : Nat) -> {auto0_ : LTmn} ->F1sa
  Reads a value from a C-pointer at the given position.

Totality: total
Visibility: export
set : SizeOfa=>CArraysna->SetPtra=>Finn->a->F1's
  Writes a value to a C pointer at the given position.

Totality: total
Visibility: export
setIx : SizeOfa=>CArraysna->SetPtra=> (0m : Nat) ->Ix (Sm) n=>a->F1's
  Writes a value to a C pointer at the given position.

Totality: total
Visibility: export
setNat : SizeOfa=>CArraysna->SetPtra=> (m : Nat) -> {auto0_ : LTmn} ->a->F1's
  Writes a value to a C pointer at the given position.

Totality: total
Visibility: export
writeVect : SizeOfa=>CArraysna->SetPtra=>Vectna->F1's
  Writes the values from a vector to a C pointer

Totality: total
Visibility: export
withIArray : SizeOfa=>CArraysna-> (CIArrayna->b) ->F1sb
  Temporarily wraps the mutable array in an immutable wrapper and
run a computation with that.

This is safe, because the pure function cannot possibly share the
immutable array by storing it in a mutable reference. It is
referentially transparent, because we call it from a linear context.

Totality: total
Visibility: export
writeList : SizeOfa=>SetPtra=> (as : Lista) ->CArrays (lengthas) a->F1's
  Writes the values from a list to a C pointer

Totality: total
Visibility: export
withCArray : SizeOfa=> (n : Nat) -> (CArraysna->F1sb) ->b
Totality: total
Visibility: export
malloc : Lift1sf=> (0a : Type) ->SizeOfa=> (n : Nat) ->f (CArraysna)
  Allocates a new C-pointer of `sizeof a * n` bytes.

Totality: total
Visibility: export
calloc : Lift1sf=> (0a : Type) ->SizeOfa=> (n : Nat) ->f (CArraysna)
  Like `malloc` but resets all allocated bytes to zero.

Totality: total
Visibility: export
free : Lift1sf=>CArraysna->f ()
  Frees the memory allocated for a C-array.

Note: Only call this if the C array is no longer used and has been
allocated via a call to `malloc` or `alloc` (either in C land
or in Idris). Afterwards, it is no longer safe to use the array
for reading or writing, nor is it safe to call `free` on it again.

For safe resource management, use the linear version of
C arrays if possible. Otherwise, consider using a safer monad
than `IO` if possible.

Totality: total
Visibility: export
fromList : Lift1sf=>SizeOfa=>SetPtra=> (as : Lista) ->f (CArrays (lengthas) a)
Totality: total
Visibility: export