flix

0.79.0

Indexable

trait Indexable[t: Type]Source

Trait for types that map indices to elements.

The mapping from indices (Idx) to elements (Elm) can be partial or total. The mapping can be accessed by get.

If all indices might not be defined (e.g. only a range of integers is valid) then then Aef should include an error like OutOfBounds or KeyNotFound.

Note that the set of defined indices can be infinite which does not naturally allow iteration. An integer map with a default element would always contain all integers indices. This implies that iteration would go through all integers.

Associated Types

type Aef: EffSource

The effect of get.

type Elm: TypeSource

The return type of get and the type of elements in the data structure.

type Idx: TypeSource

The argument type of get, used to access the elements of the data structure.

Instances

Primitives
Array[a, r], Vector[a]
Non-primitives
DelayMap[k, v], Map[k, v], MultiMap[k, v], MutHashMap[k, v, r], MutList[a, r], MutMap[k, v, r]

Signatures

def get(t: t, i: Idx[t]): Elm[t] \ Aef[t] with Indexable[t]§ Source

Retrieve the element at index i in t.