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.
The ~untyped, ~lazy or ~accomodating, and ~fuel modifiers can be combined within a module, each on its own line, and the combination can be declared 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.