I will set this question in a very practical way. Let's say we have a web-form data received as JSON at the backend together with the schema (for instance, some version of JSON schema), something like: {"data": {...}, "schema": {...}}. An important thing is, that backend can validate the data according to the type definition, given in the schema.

Is my intuition right, that we can't really have static type checking in many widely used statically typed programming languages for the data+schema structure, because in a sense data are given with their type definition representation?

Of course, we can have some approximate type checking, for example, that schema has valid structure and JSON type is valid, but we can't really statically type-check the data according to the schema.

Is the above understanding correct? And if it's correct, would it be also correct to say, that we need a static type-system with dependent types to be able to fully type-check the form data? Or are there other (less powerful than dependent types), which can make it possible the described type-check?

Please, note, that web form and JSON and it's schema is just an example. It can be XML+schema or any other equally powerful data format, so this question is actually very general. (If there is some good scientific term for defining types in the runtime data as opposed to code, please let me know.)



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.