Is there any programming language out there that allows the same set of tools it offers, to be used at the type level as well? I know, Haskell and some other ML family languages allow parametric types but those are usually very limited and have a very adhoc syntax to define a new type.
To clarify, imagine the following pseudo code:
person = { name: 'jon', lastName: 'doe', age: 600 }
assoc = (k, v, obj) =>
returns { name: 'jon', lastName: 'doe', age: 600, k: v }
assoc('color', 'red', person)
// evaluates to { name: 'jon', lastName: 'doe', age: 600, color: 'red' }
So this is at the value-level. But I'm looking for a language that allows me to do the same thing at the type level:
type Person = { name: String, lastName: String, age: Int }
type Color = Red | Yellow
assoc = (k, v, type) =>
returns a new type { name: String, lastName: String, age: Int, k: v }
assoc(color, Color, Person)
// evaluates to { name: String, lastName: String, age: Int, color: Color }
You get the point, right? Basically, things that the PL allows you to do on values can be done on the types as well. It treats types as values, if you will.