AmpersandTarski / Ampersand

Build database applications faster than anyone else, and keep your data pollution free as a bonus.
http://ampersandtarski.github.io/
GNU General Public License v3.0
40 stars 8 forks source link

Isolate the schema #1406

Open stefjoosten opened 1 year ago

stefjoosten commented 1 year ago

Problem

An information system specified by an Ampersand specification is subject to type checking. For this purpose, the theory introduces the schema concept, isolating all information needed by the type checker. Future features such as migration, independent compilation of interfaces, and the like, use a schema in their definition. However, the current compiler does not support schemas. To facilitate future features and to bring the implementation of the Ampersand compiler closer to the theory, we want to introduce the notion of schema in the code.

Feature

Every namespace has one schema, which can be used to check all types in that namespace. The schema of an Ampersand application contains all concepts, relations, and rules defined in an Ampersand script. This is roughly the entire script minus the population and without the INTERFACES, MEANINGS, and PURPOSES.

Business value

This feature opens up new possibilities. For example

  1. If an operational system can produce its schema, I will want to write and deploy new interfaces to enhance the functionality of an existing system. Deployment of such interfaces can then become possible without recompiling the entire system, effectively turning them into microservices.
  2. When migrating an operational system to accommodate a new schema, I want to pull the schema from the existing system so the software can compare it with the schema after migration.

This also enhances the maintainability of the Ampersand compiler when the schema is a recognizable Haskell data structure inside it.

Task

  1. Let the compiler produce a schema from an Ampersand script, for documentation purposes.
  2. Let the compiler check whether a new functionality (i.e. a script with just an interface) complies with a given schema, for the purpose of type-safely adding that functionality to a deployed application.