What are the benefits of top-notch types?

Does anyone have any good examples where types as first-class objects come to hand?

I think it helps to simply implement some mathematical concepts, indeed, these are the examples I'm looking for.

UPD To clarify the question, what can be done if it is possible to make functions that accept types and return types, or store types in variables?

I am studying Aldor , although due to a license issue, he is a little dead. There, types are called first-class objects, at least above.

+4
source share
3 answers

Take a look at Agda2, ats-lang.org, and other dependent-type languages. Not quite what you requested, but related.

+2
source

Reflection

If types are first-class objects, you can do reflection .

+1
source

Dynamic factory.

_types = {} register_type(typ, iden): _types[iden] = typ def factory(iden): typ = _types.get(iden) if not typ: raise ValueError('Type not registered for %r' % iden) return typ() register_type(SomeClass, 'class1') register_type(SomeOtherClass, 'class2') print factory('class1') 
+1
source

All Articles