liquidsoap icon indicating copy to clipboard operation
liquidsoap copied to clipboard

Generic language types

Open toots opened this issue 1 year ago • 0 comments

This PR extracts the operational logic required when working with types to allow modular type definition. This makes it possible to implement new types in isolation from the main operational code.

As an example application, type alias are added to the language, currently limited to ground types:

  let type foo = int
  let x = (123:foo)
  let y = (x:int)
  let z = x+y+1

  let type gni = [foo]
  let x = ([1,2,3]:gni)
  let y = (x:[int])

  let type gno = { gni: gni, foo: foo}
  let x = ({gni=[1,2,3], foo=123}:{gni:[int], foo:int})
  let y = (x:gno)

Type alias is not fully abstracted, for now custom types are expected to be matched only to their same type, much like with ground types. However, can now have a better granularity on contraints (format type is no longer orderable!) and other specific type properties.

Future use of these changes:

  • Private type aliases!
  • Domain-specific type for content/kind

toots avatar Jul 24 '22 15:07 toots