4 ms·
What would be User x Role? Is it (Name x Password x Role) x (Normal + Admin) = ? What data-structure would that represent?
by galaxyLogic 2y ago
What would be User x Role?
Is it
(Name x Password x Role) x (Normal + Admin)
= ?
What data-structure would that represent?
- noelwelsh 2y agoIf User = Name x Password x Role and Role = Normal + Admin Then (Name x Password x Role) x (Normal + Admin) = (Name x Password x Role) x Role = Name x Password x Role x Role (See the normal rules of algebra apply) In Ocaml you would write type Something = User * Role or type Something = Name * Password * Role * Role In Typescript you would have something like type Something = { user: User, role: Role } or type Something = { name: Name, password: Password, role1: Role, role2: Role } These two types are isomorphic (they have the same structure when you ignore irrelevant details) but you'd program with them slightly differently. Neither type makes a great deal of sense, but it's what you asked for. :-)