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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
| | ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Andy Wingo <wingo@pobox.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix potluck environment))
;;; Commentary:
;;;
;;; This module's public interface forms a safe set of stable bindings
;;; available to Guix potluck package definition files.
;;;
;;; Code:
(define-syntax-rule (define-bindings module-name binding ...)
(module-use! (module-public-interface (current-module))
(resolve-interface 'module-name #:select '(binding ...))))
;; Core bindings.
(define-bindings (guile)
and
begin
apply
call-with-values
values
case
case-lambda
case-lambda*
cond
define
define*
define-values
do
if
lambda
lambda*
let
let*
letrec
letrec*
or
quasiquote
quote
;; Can't allow mutation to globals.
;; set!
unless
unquote
unquote-splicing
when
while
λ)
;; Macro bindings.
(define-bindings (guile)
;; Although these have "current" in their name, they are lexically
;; scoped, not dynamically scoped.
current-filename
current-source-location
;; A subset of Guile's macro capabilities, for simplicity.
define-syntax
define-syntax-parameter
define-syntax-rule
identifier-syntax
let-syntax
letrec-syntax
syntax-error
syntax-rules)
;; Iteration bindings.
(define-bindings (guile)
compose
for-each
identity
iota
map
map-in-order
const
noop)
;; Unspecified bindings.
(define-bindings (guile)
unspecified?
*unspecified*)
;; Predicate bindings.
(define-bindings (guile)
->bool
and-map
and=>
boolean?
eq?
equal?
eqv?
negate
not
or-map)
;; The current ports (current-input-port et al) are dynamically scoped,
;; which is a footgun from a sandboxing perspective. It's too easy for
;; a procedure that is the result of a sandboxed evaluation to be later
;; invoked in a different context and thereby be implicitly granted
;; capabilities to whatever port is then current. This is compounded by
;; the fact that most Scheme i/o primitives allow the port to be omitted
;; and thereby default to whatever's current. For now, sadly, we avoid
;; exposing any i/o primitive to the sandbox.
;; Error bindings.
(define-bindings (guile)
error
throw
with-throw-handler
catch
;; false-if-exception can cause i/o if the #:warning arg is passed.
;; false-if-exception
strerror
scm-error)
;; Sort bindings.
(define-bindings (guile)
sort
sorted?
stable-sort
sort-list)
;; Alist bindings.
(define-bindings (guile)
acons
assoc
assoc-ref
assq
assq-ref
assv
assv-ref
sloppy-assoc
sloppy-assq
sloppy-assv)
;; Number bindings.
(define-bindings (guile)
*
+
-
/
1+
1-
<
<=
=
>
>=
abs
acos
acosh
angle
asin
asinh
atan
atanh
ceiling
ceiling-quotient
ceiling-remainder
ceiling/
centered-quotient
centered-remainder
centered/
complex?
cos
cosh
denominator
euclidean-quotient
euclidean-remainder
euclidean/
even?
exact->inexact
exact-integer-sqrt
exact-integer?
exact?
exp
expt
finite?
floor
floor-quotient
floor-remainder
floor/
gcd
imag-part
inf
inf?
integer-expt
integer-length
integer?
lcm
log
log10
magnitude
make-polar
make-rectangular
max
min
modulo
modulo-expt
most-negative-fixnum
most-positive-fixnum
nan
nan?
negative?
numerator
odd?
positive?
quotient
rational?
rationalize
real-part
real?
remainder
round
round-quotient
round-remainder
round/
sin
sinh
sqrt
tan
tanh
truncate
truncate-quotient
truncate-remainder
truncate/
zero?
number?
number->string
string->number)
;; Charset bindings.
(define-bindings (guile)
->char-set
char-set
char-set->list
char-set->string
char-set-adjoin
char-set-any
char-set-complement
char-set-contains?
char-set-copy
char-set-count
char-set-cursor
char-set-cursor-next
char-set-delete
char-set-diff+intersection
char-set-difference
char-set-every
char-set-filter
char-set-fold
char-set-for-each
char-set-hash
char-set-intersection
char-set-map
char-set-ref
char-set-size
char-set-unfold
char-set-union
char-set-xor
char-set:ascii
char-set:blank
char-set:designated
char-set:digit
char-set:empty
char-set:full
char-set:graphic
char-set:hex-digit
char-set:iso-control
char-set:letter
char-set:letter+digit
char-set:lower-case
char-set:printing
char-set:punctuation
char-set:symbol
char-set:title-case
char-set:upper-case
char-set:whitespace
char-set<=
char-set=
char-set?
end-of-char-set?
list->char-set
string->char-set
ucs-range->char-set)
;; String bindings.
(define-bindings (guile)
absolute-file-name?
file-name-separator-string
file-name-separator?
in-vicinity
basename
dirname
list->string
make-string
reverse-list->string
string
string->list
string-any
string-any-c-code
string-append
string-append/shared
string-capitalize
string-ci<
string-ci<=
string-ci<=?
string-ci<>
string-ci<?
string-ci=
string-ci=?
string-ci>
string-ci>=
string-ci>=?
string-ci>?
string-compare
string-compare-ci
string-concatenate
string-concatenate-reverse
string-concatenate-reverse/shared
string-concatenate/shared
string-contains
string-contains-ci
string-copy
string-count
string-delete
string-downcase
string-drop
string-drop-right
string-every
string-filter
string-fold
string-fold-right
string-for-each
string-for-each-index
string-hash
string-hash-ci
string-index
string-index-right
string-join
string-length
string-map
string-normalize-nfc
string-normalize-nfd
string-normalize-nfkc
string-normalize-nfkd
string-null?
string-pad
string-pad-right
string-prefix-ci?
string-prefix-length
string-prefix-length-ci
string-prefix?
string-ref
string-replace
string-reverse
string-rindex
string-skip
string-skip-right
string-split
string-suffix-ci?
string-suffix-length
string-suffix-length-ci
string-suffix?
string-tabulate
string-take
string-take-right
string-titlecase
string-tokenize
string-trim
string-trim-both
string-trim-right
string-unfold
string-unfold-right
string-upcase
string-utf8-length
string<
string<=
string<=?
string<>
string<?
string=
string=?
string>
string>=
string>=?
string>?
string?
substring
substring/copy
substring/read-only
substring/shared
xsubstring)
;; Symbol bindings.
(define-bindings (guile)
string->symbol
string-ci->symbol
symbol->string
list->symbol
make-symbol
symbol
symbol-append
symbol-interned?
symbol?)
;; Keyword bindings.
(define-bindings (guile)
keyword?
keyword->symbol
symbol->keyword)
;; Bit bindings.
(define-bindings (guile)
ash
round-ash
logand
logcount
logior
lognot
logtest
logxor
logbit?)
;; Char bindings.
(define-bindings (guile)
char-alphabetic?
char-ci<=?
char-ci<?
char-ci=?
char-ci>=?
char-ci>?
char-downcase
char-general-category
char-is-both?
char-lower-case?
char-numeric?
char-titlecase
char-upcase
char-upper-case?
char-whitespace?
char<=?
char<?
char=?
char>=?
char>?
char?
char->integer
integer->char)
;; List bindings.
(define-bindings (guile)
list
list-cdr-ref
list-copy
list-head
list-index
list-ref
list-tail
list?
null?
make-list
append
delete
delq
delv
filter
length
member
memq
memv
merge
reverse)
;; Pair bindings.
(define-bindings (guile)
last-pair
pair?
caaaar
caaadr
caaar
caadar
caaddr
caadr
caar
cadaar
cadadr
cadar
caddar
cadddr
caddr
cadr
car
cdaaar
cdaadr
cdaar
cdadar
cdaddr
cdadr
cdar
cddaar
cddadr
cddar
cdddar
cddddr
cdddr
cddr
cdr
cons
cons*)
;; Promise bindings.
(define-bindings (guile)
force
delay
make-promise
promise?)
;; Finally, the potluck bindings.
(define-bindings (guix potluck packages)
potluck-package
potluck-source)
|