/usr/share/racket/pkgs/lazy/lazy.scrbl is in racket-common 6.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | #lang scribble/doc
@(require (for-label (except-in lazy)
(only-in lazy/force ! !! !list !!list)
racket/contract
(only-in racket/promise promise?)))
@(define-syntax-rule (deflazy mod def id)
(begin
(def-mz-req mod id mz-id)
@def[id]{Lazy variant of @|mz-id|.}))
@(define-syntax-rule (def-mz-req mod id in-mz-id)
(begin
(define-syntax-rule (intro mz-id)
(begin
(require (for-label (only-in mod id)))
(define mz-id (racket id))))
(intro in-mz-id)))
@(define-syntax-rule (defprocthing* mod id ...)
(begin
(deflazy mod defprocthing id)
...))
@(define-syntax-rule (defprocthing id . rest)
(defthing id procedure? . rest))
@(define-syntax-rule (defidform* mod id ...)
(begin
(deflazy mod defidform id)
...))
@; ----------------------------------------
@(require scribble/manual)
@title{Lazy Racket}
@author["Eli Barzilay"]
@defmodulelang[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
@racketmodname[lazy] as your module's language:
@racketmod[
lazy
... @#,elem{lazy code here}...]
Function applications are delayed, and promises are automatically
forced. The language provides bindings that are equivalent to most of
the @racketmodname[racket/base] and @racketmodname[racket/list]
libraries. Primitives are strict in the expected places; struct
constructors are lazy; @racket[if], @racket[and], @racket[or] @|etc|
are plain (lazy) functions. Strict functionality is provided as-is:
@racket[begin], I/O, mutation, parameterization, etc. To have your
code make sense, you should chain side effects in @racket[begin]s,
which will sequence things properly. (Note: This is similar to
threading monads through your code---only use @racket[begin] where
order matters.)
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,
@racket[read] and @racket[printf] do the obvious thing---but note that
the language is a call-by-need, and you need to be aware when promises
are forced. There are also bindings for @racket[begin] (delays a
computation that forces all sub-expressions), @racket[when],
@racket[unless], etc. There are, however, less reliable and might
change (or be dropped) in the future.
There are a few additional bindings, the important ones are special
forms that force strict behaviour---there are several of these that
are useful in forcing different parts of a value in different ways, as
described in @secref["forcing"].
@; ----------------------------------------
@section{Lazy Forms and Functions}
@defidform*[mzscheme
lambda
define
]
@defidform*[scheme
let
let*
letrec
parameterize
define-values
let-values
let*-values
letrec-values
if
set!
begin begin0 when unless
cond case
]
@defprocthing*[scheme
values make-struct-type
cons list list* vector box
and or
set-mcar! set-mcdr! vector-set! set-box!
error printf fprintf display write print
eq? eqv? equal?
list? length list-ref list-tail append map for-each andmap ormap
member memq memv assoc assq assv reverse
caar cadr cdar cddr caaar caadr cadar caddr cdaar cdadr cddar cdddr caaaar
caaadr caadar caaddr cadaar cadadr caddar cadddr cdaaar cdaadr cdadar cdaddr
cddaar cddadr cdddar cddddr
first second third fourth fifth sixth seventh eighth rest cons? empty empty?
foldl foldr last-pair remove remq remv remove* remq* remv* memf assf filter
sort
true false boolean=? symbol=? compose build-list
take
]
@defprocthing[identity]{Lazy identity function.}
@defprocthing[cycle]{Creates a lazy infinite list that repeats its
input arguments in order.}
@; ----------------------------------------
@section[#:tag "forcing"]{Forcing Values}
@defmodule[lazy/force]
The bindings of @racketmodname[lazy/force] are re-provided by
@racketmodname[lazy].
@defproc[(! [expr any/c]) any/c]{
Evaluates @racket[expr] strictly. The result is always forced, over
and over until it gets a non-promise value.}
@defproc[(!! [expr any/c]) any/c]{
Similar to @racket[!], but recursively forces a structure (e.g:
lists).}
@defproc[(!list [expr (or/c promise? list?)]) list?]{
Forces the @racket[expr] which is expected to be a list, and forces
the @racket[cdr]s recursively to expose a proper list structure.}
@defproc[(!!list [expr (or/c promise? list?)]) list?]{
Similar to @racket[!list] but also forces (using @racket[!]) the
elements of the list.}
@;{ This moved into lazy.rkt, and all the other forces will move there too.
@subsection{Multiple values}
To avoid dealing with multiple values, they are treated as a single
tuple in the lazy language. This is implemented as a
@racket[multiple-values] struct, with a @racket[values] slot.
@defproc[(split-values [x multiple-values?]) any]{
Used to split such a tuple to actual multiple values. (This may change
in the future.)}
@defproc[(!values [expr (or/c promise? multiple-values?)]) any]{
Forces @racket[expr] and uses @racket[split-values] on the result.}
@defproc[(!!values [expr (or/c promise? multiple-values?)]) any]{
Similar to @racket[!values], but forces each of the values
recursively.}
;}
|