Bit of a strange question, but I’m pondering what is the “best” way to allow a user to create an easily-accessible number of distinct values, e.g. that might serve as unique IDs. Note: I’m probably going to use Natural
s throughout, but I don’t care what the values are, so long as they can be converted to unique Text
.
Basically, at the end of the day, I need a user to be able to make a record or union type that maps to unique values, e.g. either:
let IDs = { key1 = 1
, key2 = 2
, key3 = 3
}
in IDs.key2
or
let IDs = < Key1 | Key2 | Key3 >
let getVal : IDs -> Natural = merge ...
in getVal IDs.Key1
without having to write the = 1, = 2
or getVal
by hand.
For example, the “perfect” case would be something like this (not possible in Dhall, I’m sure):
makeIDs ["key1", "key2", "key3"]
returning
{ key1 = 1
, key2 = 2
, key3 = 3
}
Since Map
s are not accessible by their keys, this can’t be done nicely using them.
Is there any possible solution that at least ensures that a simple typo can’t create a non-unique value?