I’m working on a project to learn Elm where I have a list of tags that the user can create and add and then use to filter (they are all checkboxes). At first, I had created these as a List. However, I realized when I went to update them, I needed a key in order to know which checkbox to update when they were being checked.
I refactored to an Array, and overall this feels like a better solution. The only odd part is in order to do an update I have to do a get -> set, which leaves a Maybe that I have to default (with something that theoretically should never be used). In addition, I have to convert the Array to a list in a lot of places.
All of this left me with two questions:
- What is the “best” way or most idiomatic way to do this?
- When using an Array, what is the cost of converting to and from a list? (I’m not particularly concerned with performance, I’m more interested in understanding what’s happening under the hood)