aboutsummaryrefslogtreecommitdiffstats
path: root/mcgoron/guix/srfi.scm
blob: 0f9d71eac01fb0de820823afde5fe340854d8c39 (plain) (blame)
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
#| Copyright (C) 2025 Peter McGoron
 |
 | This program 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.
 |
 | This program 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 this program.  If not, see <https://www.gnu.org/licenses/>.
 |#

(define-module (mcgoron guix srfi)
  #:use-module (rnrs base)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (guix licenses)
  #:use-module (guix git-download)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system)
  #:use-module (guix build-system copy)
  #:use-module (guix build-system trivial)
  #:use-module (guix build-system cmake)
  #:use-module (mcgoron guix scheme-packages)
  #:use-module (guix gexp))

(define-public srfi-1-r7rs
  (package
   (name "srfi-1-r7rs")
   (version "errata-7")
   (source
    (origin (method git-fetch)
            (uri (git-reference (url "https://github.com/scheme-requests-for-implementation/srfi-1")
                                (commit "errata-7")))
            (sha256 (base32 "18lj5y85zxs0yzkdv66qd290nwms7jy27ky1x3ba9kp6hzjia5kj"))))
   (build-system copy-build-system)
   (home-page "https://srfi.schemers.org/srfi-1")
   (synopsis "List library (R7RS)")
   (license (non-copyleft "//srfi.schemers.org/srfi-1/srfi-1.html"))
   (inputs '())
   (native-inputs '())
   (description " R5RS Scheme has an impoverished set of list-processing utilities, which is a problem for authors of portable code. This SRFI proposes a coherent and comprehensive set of list-processing procedures; it is accompanied by a reference implementation of the spec. The reference implementation is

    portable
    efficient
    completely open, public-domain source
")
   (arguments
    (list
     #:phases
     #~ (modify-phases %standard-phases
          (replace 'install
            (lambda* (#:key outputs #:allow-other-keys)
              (use-modules (rnrs io ports))
              (let ((lib (string-append (assoc-ref %outputs "out")
                                        "/" #$r7rs-lib-dir
                                        "/srfi")))
                (mkdir-p lib)
                (with-output-to-file (string-append lib "/1.sld")
                  (lambda ()
                    (display "(define-library (srfi 1) (import (scheme base) (scheme cxr))\n")
                    (write
                     '(export
                       xcons make-list list-tabulate cons* list-copy
                       proper-list? circular-list? dotted-list? not-pair? null-list? list=
                       circular-list length+
                       iota
                       first second third fourth fifth sixth seventh eighth ninth tenth
                       car+cdr
                       take drop
                       take-right drop-right
                       take! drop-right!
                       split-at split-at!
                       last last-pair
                       zip unzip1 unzip2 unzip3 unzip4 unzip5
                       count
                       append! append-reverse append-reverse! concatenate concatenate!
                       unfold fold pair-fold reduce
                       unfold-right fold-right pair-fold-right reduce-right
                       append-map append-map! map! pair-for-each filter-map map-in-order
                       filter partition remove
                       filter! partition! remove!
                       find find-tail any every list-index
                       take-while drop-while take-while!
                       span break span! break!
                       delete delete!
                       alist-cons alist-copy
                       delete-duplicates delete-duplicates!
                       alist-delete alist-delete!
                       reverse!
                       lset<= lset= lset-adjoin
                       lset-union lset-intersection lset-difference lset-xor lset-diff+intersection
                       lset-union! lset-intersection! lset-difference! lset-xor! lset-diff+intersection!
                       map for-each member assoc))
                    (display "\n(begin\n")
                    (do ((f (open-input-file "srfi-1-reference.scm"))
                         (s "" (get-line f)))
                        ((eof-object? s))
                      (display s) (newline))
                    (display "))\n")))))))))))