flix

0.54.0

Indexable

trait Indexable[t: Type]Source

An Indexable instance on a type means that it has a (partial or total) mapping from indices (Idx) to elements (Elm). 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

instance Indexable[Array[a, r]]Source
instance Indexable[DelayMap[k, v]] with Order[k]Source
instance Indexable[Map[k, v]] with Order[k]Source
instance Indexable[MultiMap[k, v]] with Order[k]Source
instance Indexable[MutList[a, r]]Source
instance Indexable[MutMap[k, v, r]] with Order[k]Source
instance Indexable[Vector[a]]Source

A Vector data type which is fundamentally like Array but is immutable.

Signatures

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

Retrieve the element at index i in t.