/* * Copyright 2024 Matthew Lutze * Copyright 2024 Jonathan Lindegaard Starup * * Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE.md file. */////// Trait for types that map indices to elements, and its functions.///pubmod Indexable {////// 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.///pubtraitIndexable[t] {/// The argument type of `get`, used to access the elements of the data structure.typeIdx: Type/// The return type of `get` and the type of elements in the data structure.typeElm: Type/// The effect of `get`.typeAef: Eff/// Retrieve the element at index `i` in `t`.pubdefget(t: t, i: Indexable.Idx[t]): Indexable.Elm[t] \ Indexable.Aef[t] }}