I suspect you are right. I have a bunch of factors and these have discrete levels. Like Food: fruit, meat, bread… I want to create methods that dispatch on distinct setups, unique collections of factors-level pairs. For that I need to code the factors and their levels as types. I think…
This looks very promising indeed. Fits right in. But how would I build a NamedTuple “on the fly”? Say I have a Dict where the keys are to be the names in the NamedTuple and the values the values. How can I construct a NamedTuple out of that…?
Wait a minute, the dispatch is matched on the actual names and only the types of the values for NamedTuples, not the actual values of the values…
So a function that only accepts a will also accept b, cause the type signatures will be identical for both a and b:
a = (:food = :apple, :container = :box)
b = (:food = :meat, :container = :can)
Am I missing something? If that is the case then I’ll need to think this over. All my factor names (i.e. the name part of the named tuple) are always the same. It’s the specific level (i.e. the value part of the named tuple) that changes… It’s the level I want to dispatch on.