3 ms·
If 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
by noelwelsh 2y ago
If 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. :-)