Idris2Doc : JS.Array

JS.Array

(source)
Primitive Javascript arrays. This offers an alternative
to the functionality provided by `Data.IOArray.Prims` from base.

In addition to mutable arrays, we also provide linear arrays
for imperatively filling arrays in a pure envirionment,
as well as immutable arrays, the latter being guaranteed to always
return a value if an index is within bounds.

We use `Bits32` for indexing, as this is the type reflecting
most exactly the kinds of indices use to access array elements.
However, right now, `Bits32` is represented by `BigInt` at the Javascript
backend. This might negatively affect performance, as we always have
to convert to `Number` first (that's `Double` in Idris2).
Hopefully, the backend representation will change in the future, and
this will be no longer an issue.

In addition, `Bits32` does not offer a lot of functionality when
it comes to available proofs for it being in bounds. This
module provides a minimal amount of utilities for this, but again,
these might hopefully go elswhere, where the whole topic is treated
more thoroughly.

Definitions

Ix : Bits32->Type
  Type for indexing into an array of known size.

Totality: total
Visibility: public export
len32 : Lista->Bits32
  Calculates the length of a list as an array index.

Totality: total
Visibility: public export
zipWithIndex : (as : Lista) ->List (Ix (len32as), a)
  Zips a list of elements with the corresponding
array indices.

Totality: total
Visibility: public export
toIx : (size : Bits32) ->Bits32->Maybe (Ixsize)
  Tries to convert a number into an index for
an array of the given size.

Totality: total
Visibility: public export
dataArray : Type->Type
Totality: total
Visibility: export
Hints:
ArrayLike (Arraya) a
FromFFI (Arraya) (Arraya)
ToFFI (Arraya) (Arraya)
ToFFIab=>ToFFI (Lista) (IO (Arrayb))
interfaceArrayLike : Type->Type->Type
  Witness, that a given value represents an Array-like object.
Array-like objects must provide the following functionality in
the Javascript backend:

* a `length` property, returning the value's length as an unsigned 32bit
integer
* the ability to access values of the given `elem` type`
at a given index by means of the following syntax: `arr[12]`.

Javascript Arrays are, of course, Array-like, as are Strings.
Some other Array-likes include `NodeList` in the DOM.

Note, that this is just a witnessing interface. All functionality
is already implemented through functions `sizeIO` and `readIO`.
It is possible to clone an `ArrayLike` to an actual Javascript
Array by invoking `Array.from(v)` at the backend. This functionality
is available through `arrayDataFrom` for mutable arrays and
`arrayFrom` for immutable arrays.

Parameters: arr, el
Implementations:
ArrayLikeStringChar
ArrayLike (Arraya) a
ArrayLikeUInt8ClampedArrayBits8
ArrayLikeUInt8ArrayBits8
ArrayLikeUInt16ArrayBits16
ArrayLikeUInt32ArrayBits32
ArrayLikeInt8ArrayInt8
ArrayLikeInt16ArrayInt16
ArrayLikeInt32ArrayInt32
ArrayLikeFloat64ArrayDouble
ArrayLike (IArraya) a
sizeIO : (HasIOio, ArrayLikearrel) =>arr->ioBits32
Totality: total
Visibility: export
readIO : (HasIOio, ArrayLikearre) =>arr->Bits32->io (Maybee)
Totality: total
Visibility: export
interfaceIArrayLike : Type->Type->Type
  Witness, that a given value represents an immutable
Array-like object. The same rules as for `ArrayLike`
hold, with the addition, that values of types implementing
this interface must be immutable.
It is then safe to provide pure versions of `readIO` and `sizeIO`.

Parameters: arr, el
Constraints: ArrayLike arr el
Implementations:
IArrayLikeStringChar
IArrayLike (IArraya) a
size : IArrayLikearrel=>arr->Bits32
Totality: total
Visibility: export
read : {auto{conArg:7478} : IArrayLikearrel} -> (elems : arr) ->Ix (sizeelems) ->el
Totality: total
Visibility: export
readMaybe : IArrayLikearrel=>arr->Bits32->Maybeel
Totality: total
Visibility: export
sameElements : (IArrayLikearrel, Eqel) =>arr->arr->Bool
  Returns true if the given immutable arrays contain
the same elements in the same order.

Totality: total
Visibility: export
foldlArray : IArrayLikearrel=> (acc->el->acc) ->acc->arr->acc
Totality: total
Visibility: export
foldrArray : IArrayLikearrel=> (el->acc->acc) ->acc->arr->acc
Totality: total
Visibility: export
arrayToList : IArrayLikearrel=>arr->Listel
Totality: total
Visibility: export
isArray : anyVal->Bool
Totality: total
Visibility: export
writeIO : HasIOio=>Arraya->Bits32->a->io ()
Totality: total
Visibility: export
newArrayIO : HasIOio=>Bits32->io (Arraya)
Totality: total
Visibility: export
arrayDataFrom : (HasIOio, ArrayLikearre) =>arr->io (Arraye)
Totality: total
Visibility: export
fromListIO : HasIOio=>Lista->io (Arraya)
Totality: total
Visibility: export
fromFoldableIO : (HasIOio, Foldablet) =>ta->io (Arraya)
Totality: total
Visibility: export
recordLinArray : Bits32->Type->Type
  A linear wrapper around a primitive array.

Totality: total
Visibility: export
Constructor: 
MkLinArray : Arraya->LinArrayszea

Projection: 
.array : LinArrayszea->Arraya
thaw : (1_ : LinArrayszea) ->IO (Arraya)
Totality: total
Visibility: export
emptyArray : (1_ : ((1_ : LinArray0a) ->b)) ->b
Totality: total
Visibility: export
newArray : a-> (sze : Bits32) -> (1_ : ((1_ : LinArrayszea) ->b)) ->b
Totality: total
Visibility: export
withArray : {auto{conArg:8509} : IArrayLikearrel} -> (v : arr) -> (1_ : ((1_ : LinArray (sizev) el) ->a)) ->a
Totality: total
Visibility: export
write : (1_ : LinArrayszea) ->Ixsze->a->LinArrayszea
Totality: total
Visibility: export
lread : (1_ : LinArrayszea) ->Ixsze->Resa (const (LinArrayszea))
Totality: total
Visibility: export
lsize : (1_ : LinArrayszea) ->ResBits32 (\s=>LinArraysa)
Totality: total
Visibility: export
iterate' : (sze : Bits32) -> (Ixsze->a) -> ((1_ : LinArrayszea) ->b) ->b
Totality: total
Visibility: export
fromList' : (as : Lista) -> ((1_ : LinArray (len32as) a) ->b) ->b
Totality: total
Visibility: export
map' : {auto{conArg:8773} : IArrayLikearra} -> (vs : arr) -> ((1_ : LinArray (sizevs) b) ->c) -> (a->b) ->c
Totality: total
Visibility: export
totalSize : (IArrayLikearr1arr2, IArrayLikearr2el) =>arr1->Bits32
Totality: total
Visibility: export
join' : {auto{conArg:8860} : IArrayLikearr1arr2} -> {auto{conArg:8863} : IArrayLikearr2el} -> (vss : arr1) -> ((1_ : LinArray (totalSizevss) el) ->a) ->a
  Concatenates to nested layers of immutable
array-like objects.

Totality: total
Visibility: export
recordIArray : Type->Type
  An immutable array from a resource that guarantees, that
this will not be modified any more.

Typically, these are generated by freezing a `LinArray`
or by cloning an `ArrayLike` value.

Totality: total
Visibility: export
Constructor: 
MkIArray : Arraya->IArraya

Projection: 
.array : IArraya->Arraya

Hints:
AlternativeIArray
ApplicativeIArray
ArrayLike (IArraya) a
Eqel=>Eq (IArrayel)
FoldableIArray
FromString (IArrayChar)
FunctorIArray
IArrayLike (IArraya) a
MonadIArray
Monoid (IArraya)
Semigroup (IArraya)
Showa=>Show (IArraya)
TraversableIArray
freezeCloneIO : (HasIOio, ArrayLikearrel) =>arr->io (IArrayel)
Totality: total
Visibility: export
freeze : (1_ : LinArrayszea) ->IArraya
Totality: total
Visibility: export
fromList : Lista->IArraya
Totality: total
Visibility: export
singleton : a->IArraya
Totality: total
Visibility: export
concat : IArray (IArraya) ->IArraya
Totality: total
Visibility: export