Closed mlutze closed 1 year ago
Lenses? Half-kidding.
If you propose an API we could implement it in both Flix and Scala.
Something like this?
enum DeepMap[k1, k2, v](Map[k1, Map[k2, v]])
def putDeep(k1: k1, k2: k2, v: v, m: DeepMap[k1, k2, v]) =
let DeepMap(outer) = m;
let inner = outer |> Map.getOrDefault(k1);
let newInner = inner |> Map.put(k2, v);
let newOuter = outer |> Map.put(k1, newInnder);
DeepMap(newOuter)
I think it's too specialized to add to the standard library.
Seems too specialized.
Closing since Magnus doesn't like it :P
In the Namer we have a big block where many times we have to access and modify a map within a map, leading to code that looks like
It's difficult to read and easy to make a mistake. I'd like to introduce some new structure that makes the nested map easier to manipulate.