Lazy Racket
#lang lazy |
Lazy Racket is available as both a language level and a module that can be used to write lazy code. To write lazy code, simply use lazy as your module’s language:
#lang lazy ... lazy code here...
Function applications are delayed, and promises are automatically
forced. The language provides bindings that are equivalent to most of
the racket/base and racket/list
libraries. Primitives are strict in the expected places; struct
constructors are lazy; if, and, or etc.
are plain (lazy) functions. Strict functionality is provided as-is:
begin, I/O, mutation, parameterization, etc. To have your
code make sense, you should chain side effects in begins,
which will sequence things properly. (Note: This is similar to
threading monads through your code—
Mixing lazy and strict code is simple: you just write the lazy code in the lazy language, and strict code as usual. The lazy language treats imported functions (those that were not defined in the lazy language) as strict, and on the strict side you only need to force (possibly recursively) through promises.
A few side-effect bindings are provided as-is. For example,
read and printf do the obvious thing—
There are a few additional bindings, the important ones are special
forms that force strict behaviour—
1 Lazy Forms and Functions
or : procedure?
2 Forcing Values
(require lazy/force) |
The bindings of lazy/force are re-provided by lazy.