Back to Enso

Goals for the Enso Type System

docs/types/goals.md

2025.3.42.0 KB
Original Source

Goals for the Enso Type System

In our design for Enso, we firmly believe that the type system should be able to aid the user in writing correct programs, far and above anything else. However, with so much of our targeted user-base being significantly non-technical, it needs to be as unobtrusive as possible.

<!-- MarkdownTOC levels="2,3" autolink="true" --> <!-- /MarkdownTOC -->

High-Level Goals

The high-level goals for the Enso type system are as follows:

[!WARNING] Not a goal anymore: Enso is a dynamic language. Static type inference is not needed for execution. As such static typing is an optional component - more a linter than essential part of the system.

Inference should have maximal power. We want users to be forced to write type annotations in as few situations as possible. This means that, ideally, we are able to infer higher-rank types and make impredicative instantiations without annotations.

Error messages must be informative

Clear error messages are essential for figuring out what the user needs to change in own program to eliminate the error. This is true for both:

Ideally a type error shall contain proper identification of the error origin/location and clear indication of what shall be changed to eliminate it.

Early Runtime Type Errors

Type checks shall be performed at the "library boundary" rather than somewhere deep inside of library code. Only then the user can under the context of the error.

Powerful Enough Type System

Enso aim is to provide a powerful enough type system to support development done by non-technical audience. The type system shouldn't require master degree in computer science to be used properly. As such the types are fully optional and can be added gradually - usually only when a sample project is turned into a reusable library.