On this page:
12.1 Untyped Mode
12.2 Lazy Mode
12.3 Inference Fuel
12.4 Type-Error Source Mode

12 Language Options🔗ℹ

Keyword language options written immediately after #lang shplait change the language that is implemented by #lang shplait. “Immediately after” means that no definitions or expressions can appear before a keyword but whitespace and comments can precede a keyword.

language_option

 = 

~untyped

 | 

~lazy

 | 

~accomodating

 | 

~fuel nonnegative_integer

 | 

~type_source_mode source_mode

 

source_mode

 = 

none

 | 

proximate

 | 

all

Multiple modifiers can be combined within a module, each on its own line, and in any order. Only one of ~lazy and ~accomodating can be used.

12.1 Untyped Mode🔗ℹ

The ~untyped language option disables type checking. The syntax of a shplait module is the same with and without ~untyped, but types are ignored when ~untyped is specified. An untyped Shplait module can interoperate with a typed Shplait module, but soundness guarantees normally provided by Shplait are not preserved.

12.2 Lazy Mode🔗ℹ

The ~lazy language option changes Shplait to lazy evaluation. The syntax and type system are unchanged, but the evaluation of certain expression positions are delayed until forced (by a test or by printing, ultimately):

  • the right-hand side of a definition;

  • argument in a function call (including calls to variant constructors);

  • expressions for elements in a list construction using [], in a tuple using values, or an array using Array;

  • expressions for values (not keys) in a map construction using {}; and

  • the right-hand side of an assignment

  • ... but expressions fitting the value grammar are not delayed.

Printing a value forces all components of the value, such as elements of a list. Note that every module-level expression’s result is printed, unless the result is #void, so that forces results. Accessing just one component of a compound value (such as an element of a list) will not force the other components. Names of predefined functions like map refer to a lazy variant in a lazy context or an eager variant in an eager context.

A lazy Shplait module will not interoperate well with an eager module in general, but use ~accomodating in place of ~lazy to define a Shplait module that uses eager evaluation and can interoperate with a lazy Shplait module.

12.3 Inference Fuel🔗ℹ

Use ~fuel amount as a language option to specify how much effort should be spent resolving potentially cyclic dependencies due to inference of polymorphic recursion. The default fuel amount is 100.

12.4 Type-Error Source Mode🔗ℹ

Use ~type_source_mode source_mode to configure the way that source locations are reported in type-error messages. The all mode, which is the default, shows a set of source locations that inference discovers to be consistent. The proximate mode prunes that set to a single source location that reflects an immediate point where inference and type checking failed (after potentially gathering information from other locations). The none mode disables source-location reporting in type-error messages.