Trying to figure out a good way to model the concept of a fixed number of "slots" that can either hold something or not.
➡️ Tried using List(a), but it either requires a lot of let assert or dealing with Result(a, Nil) everywhere because technically the index might be out of bounds (annoying for "get and update" operations in particular). Also means when you delete an element it can change which slot(/index) other elements are in, which isn't a deal-breaker but would be nice to avoid.
➡️ Started looking into a #(Option(a), Option(a), Option(a)) tuple, but couldn't work out how to do "insert this element into the first empty slot" without either a big pattern-match on every possible combination of Some and None, or re-introducing the let assert/Result issues by going through a list.
➡️ Now looking at a Map(ID, a) with:
type ID {
Slot1
Slot2
Slot3
}
...but once again got stuck on "insert element into first empty slot". To determine whether all slots are already filled, I'd want to iterate all the constructors of ID, which I think just has to be a hard-coded list since you can't get the type info at runtime; but then if (say) I add a Slot4 later, the code would still compile but the "insert" function would incorrectly act like there were only 3 slots.
Very possible there are other, better options (heh) I'm missing here.