Type System

Motivation: This is the type system for the gitlab application. It helps to ensure that code is correct and reliable, making it easier to maintain and extend.

Description: The type system is designed to be flexible and adaptable. It provides a number of options for declaring types, including:

  • Basic types: These are the fundamental building blocks of the type system. They include String, Integer, Float, Boolean, and Array.

  • Custom types: These are user-defined types that represent specific data structures. They can be created using the type keyword and can be extended with methods.

  • Optional types: These types represent values that may or may not be present. They are declared using the ? suffix.

  • Union types: These types represent values that can be one of several types. They are declared using the | operator.

  • Intersection types: These types represent values that must be both of two types. They are declared using the & operator.

Examples:

  • Basic types:
name: String
          age: Integer
          is_active: Boolean
          
  • Custom types:
type User
            name: String
            age: Integer
            is_active: Boolean
          end
          
  • Optional types:
name: String?
          age: Integer?
          
  • Union types:
status: :active | :inactive | :pending
          
  • Intersection types:
user: User & { isAdmin: Boolean }
          

Source: