Skip to content

Expressions as type parameters? #28

@lars-reimann

Description

@lars-reimann

Is your feature request related to a problem? Please describe.
Example use cases:

  • Type parameter isTrained
  • Number of instances

Describe the solution you'd like
In addition to type parameters that are types, we could have type parameters that are expressions. We should probably introduce different kinds for type parameters if we do this (hard-coded, not extensible):

  • CallableType (or $CallableType) (probably not needed)
  • ExpressionType (or $ExpressionType) (new)
    • IntType (or $IntType)
    • FloatType (or $FloatType)
    • BooleanType (or $BooleanType)
    • StringType (or $StringType)
  • NamedType (or $NamedType)
  • UnionType (or $UnionType) (probably not needed)

Possible notation for kinds:

Class C<T::IntType>

or we reuse the : we already have for types (a kind being a type of types).

Additional context (optional)

  • Type parameters are meant as parameters of types rather than parameters that are types.
  • Without some prefix like expr this will only work for a subset of expressions (references + member accesses are problematic since they clash with named types and member types).
  • At the very least we should offer literals + arithmetic & logical operations
  • Relates to Schema checking for tables #37 (which could be expressed by adding a SchemaType)
  • Set of kinds can be hard-coded.
  • Also: optional type parameters?

Metadata

Metadata

Assignees

Labels

dsl 🗒️Issues regarding the domain specific programming language

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions