diff options
-rw-r--r-- | .dir-locals.el | 4 | ||||
-rw-r--r-- | README.md | 44 | ||||
-rw-r--r-- | chicanery.egg | 11 | ||||
-rw-r--r-- | chicanery.scm | 94 |
4 files changed, 48 insertions, 105 deletions
diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..9c78ce8 --- /dev/null +++ b/.dir-locals.el | |||
@@ -0,0 +1,4 @@ | |||
1 | ;;; Directory Local Variables -*- no-byte-compile: t -*- | ||
2 | ;;; For more information see (info "(emacs) Directory Variables") | ||
3 | |||
4 | ((scheme-mode . ((geiser-scheme-implementation . chicken)))) | ||
diff --git a/README.md b/README.md index 6c720b7..71083ad 100644 --- a/README.md +++ b/README.md | |||
@@ -1,49 +1,33 @@ | |||
1 | # Chicanery: subtle, opinionated improvements to R7RS Scheme (in CHICKEN) | 1 | # Chicanery: subtle, opinionated improvements to R7RS Scheme for CHICKEN |
2 | 2 | ||
3 | While I was reading the [R7RS | 3 | While I was reading the [R7RS specification][r7rs], I was a little annoyed by how broken up the standard library seemed to be. While the most egregious example is maybe `(scheme case-lambda)`, which exports ... only `case-lambda`, the other libraries like `(scheme write)` for `display`, `(scheme cxr)` for functions like `caddr` but not `cddr`, and the rest didn't really seem logical to me. Plus, in CHICKEN scheme, the one I usually use, `utf8` is an egg you need to install separately... |
4 | specification](https://standards.scheme.org/official/r7rs.pdf), I was a little | ||
5 | annoyed by how broken up the standard library seemed to be. While the most | ||
6 | egregious example is maybe `(scheme case-lambda)`, which exports ... only | ||
7 | `case-lambda`, the other libraries like `(scheme write)` for `display`, `(scheme | ||
8 | cxr)` for functions like `caddr` but not `cddr`, and the rest didn't really seem | ||
9 | logical to me. Plus, in CHICKEN scheme, the one I usually use, `utf8` is an egg | ||
10 | you need to install separately... | ||
11 | 4 | ||
12 | To ameliorate these minor warts in what I otherwise consider to be an excellent | 5 | To ameliorate these minor warts in what I otherwise consider to be an excellent |
13 | language, `chicanery` was born. It's kind of like a prelude, I suppose? It | 6 | language, `chicanery` was born. It's kind of like a prelude, I suppose? It |
14 | imports all `r7rs` modules and re-exports their identifiers, and makes sure the | 7 | imports all `r7rs` modules and re-exports their identifiers, and makes sure the |
15 | implementation is Unicode-aware. It also includes a few extras ;) | 8 | implementation is Unicode-aware. |
16 | 9 | ||
17 | ## Chicanery extras | 10 | ## Chicanery extras |
18 | 11 | ||
19 | I also thought it was strange that `map`, `for-each`, and `append` apply to | 12 | The following are included in the chicanery library because I like them. |
20 | lists only, while `vector-map` and `string-for-each`, exist, for example. | ||
21 | `chicanery` prefixes the default `map`, `for-each`, and `append` functions with | ||
22 | `list-`, and redefines those identifiers to functions that are generic over | ||
23 | Scheme's base collection types (lists, strings, vectors, bytevectors where | ||
24 | applicable). I didn't make the functions fully-generic to keep them efficient | ||
25 | and because I don't know how to do that, but you can still use `vector-append` | ||
26 | or `list-map` if you know what type you need and want speed. | ||
27 | 13 | ||
28 | In a similar vein, I've also added generic functions `ref` and `copy` that | 14 | - `(atom? x)` determines whether `x` is an atom (i.e., not a pair or null) |
29 | dispatch to `string-ref`, `list-copy`, and the like. | 15 | - `(slurp [port])` reads a port until hitting end-of-file (IDK |
30 | 16 | why this isn't in R7RS!) | |
31 | Other extras include | ||
32 | |||
33 | - `(atom? x)` determines whether `x` is an atom (i.e., not a pair or null) | ||
34 | - `(read-port)`, `(read-port port)` reads a port until hitting end-of-file (IDK | ||
35 | why this isn't in R7RS!), in chunks of `read-port-chunk-size` | ||
36 | - `(defined? x)` returns whether the symbol `x` is bound to a variable | ||
37 | - `(with-input-from-string str thunk)` calls `thunk` with `str` bound as the current-input-port. | 17 | - `(with-input-from-string str thunk)` calls `thunk` with `str` bound as the current-input-port. |
38 | - `(with-output-to-string thunk)` calls `thunk` and returns a string of the output. | 18 | - `(with-output-to-string thunk)` calls `thunk` and returns a string of the output. |
39 | - `(displayed x)`, `(->string x)` returns `x` as a string (via `display`) | 19 | - `(displayed x)`, `(->string x)` returns `x` as a string (via `display`) |
40 | - `(written x)` returns `x` as a string (via `write`) | 20 | - `(written x)` returns `x` as a string (via `write`) |
41 | - `(print x ...)` displays `x ...` followed by a newline | 21 | - `(print . xs)` displays `xs` followed by a newline |
42 | 22 | ||
43 | ## Todo | 23 | ## Todo |
44 | 24 | ||
45 | - Support multiple scheme implementations. I tried doing this (see the [multiple-impls](https://git.acdw.net/chicanery/?h=multiple-impls) branch), but it kept not working in weird ways, plus it was like whack-a-mole with all the different schemes and just exhausting. | 25 | - Support multiple scheme implementations. I tried doing this (see the [multiple-impls][] branch), but it kept not working in weird ways, plus it was like whack-a-mole with all the different schemes and just exhausting. |
46 | 26 | ||
47 | ## License | 27 | ## License |
48 | 28 | ||
49 | This software is licensed under the GWL, v. 1.0. See [COPYING](https://git.acdw.net/chicanery/tree/COPYING) for details. | 29 | This software is licensed under the GWL, v 1.0. See [COPYING][copying] for details. |
30 | |||
31 | [r7rs]: https://standards.scheme.org/official/r7rs.pdf | ||
32 | [multiple-impls]: https://git.acdw.net/chicanery/?h=multiple-impls | ||
33 | [copying]: https://git.acdw.net/chicanery/tree/COPYING | ||
diff --git a/chicanery.egg b/chicanery.egg index 2bce2f1..d894ab2 100644 --- a/chicanery.egg +++ b/chicanery.egg | |||
@@ -1,5 +1,3 @@ | |||
1 | ;; chicanery -*- scheme -*- | ||
2 | |||
3 | ((synopsis "Subtly breaking scheme expectations.") | 1 | ((synopsis "Subtly breaking scheme expectations.") |
4 | (author "Case Duckworth") | 2 | (author "Case Duckworth") |
5 | (version "0.3.0") | 3 | (version "0.3.0") |
@@ -9,8 +7,9 @@ | |||
9 | (components | 7 | (components |
10 | (extension chicanery | 8 | (extension chicanery |
11 | (source chicanery.scm) | 9 | (source chicanery.scm) |
12 | (types-file) ; I don't know what this does ... | 10 | (types-file) |
13 | (inline-file) | 11 | (inline-file) |
14 | (csc-options "-X" "r7rs" "-R" "r7rs" | 12 | (csc-options -X r7rs -R r7rs |
15 | "-X" "utf8" "-R" "utf8" | 13 | -X utf8 -R utf8 |
16 | "-no-warnings")))) | 14 | -no-warnings) |
15 | (source-dependencies extras.scm)))) | ||
diff --git a/chicanery.scm b/chicanery.scm index 0fc71e4..4dba4ca 100644 --- a/chicanery.scm +++ b/chicanery.scm | |||
@@ -1,9 +1,9 @@ | |||
1 | ;;; chicanery --- subtly breaking scheme expectations | 1 | (module chicanery () |
2 | (import scheme | ||
3 | (chicken module) | ||
4 | (chicken platform)) | ||
5 | (import r7rs utf8) | ||
2 | 6 | ||
3 | (import (r7rs)) | ||
4 | |||
5 | (define-library chicanery | ||
6 | ;; All the scheme stuff in one place | ||
7 | (import (scheme base)) | 7 | (import (scheme base)) |
8 | (import (scheme case-lambda)) | 8 | (import (scheme case-lambda)) |
9 | (import (scheme char)) | 9 | (import (scheme char)) |
@@ -19,69 +19,25 @@ | |||
19 | (import (scheme repl)) | 19 | (import (scheme repl)) |
20 | (import (scheme time)) | 20 | (import (scheme time)) |
21 | (import (scheme write)) | 21 | (import (scheme write)) |
22 | (import utf8) | ||
23 | (export * + - / <= < >= = > abs and #;append apply assoc assq assv begin | ||
24 | binary-port? boolean? boolean=? bytevector bytevector-append | ||
25 | bytevector-copy bytevector-copy! bytevector-length bytevector-u8-ref | ||
26 | bytevector-u8-set! bytevector? car cdr caar cadr cdar cddr | ||
27 | call-with-current-continuation call/cc call-with-port call-with-values | ||
28 | case ceiling char-ready? char->integer integer->char char=? char<? | ||
29 | char>? char<=? char>=? char? close-input-port close-output-port | ||
30 | close-port complex? cond cond-expand cons current-input-port | ||
31 | current-output-port current-error-port define define-record-type | ||
32 | define-syntax define-values denominator numerator do dynamic-wind | ||
33 | eof-object eof-object? eq? eqv? equal? error error-object-irritants | ||
34 | error-object-message error-object? even? odd? exact inexact | ||
35 | exact-integer-sqrt exact-integer? exact? inexact? exp expt features | ||
36 | file-error? floor floor/ floor-quotient floor-remainder | ||
37 | flush-output-port #;for-each gcd lcm get-output-bytevector | ||
38 | get-output-string guard if import import-for-syntax include include-ci | ||
39 | input-port-open? output-port-open? input-port? output-port? integer? | ||
40 | lambda length let let* letrec letrec* let-values let*-values let-syntax | ||
41 | letrec-syntax list list-copy list-ref list-set! list-tail list? | ||
42 | list->vector make-bytevector make-list make-parameter make-string | ||
43 | make-vector #;map max min member memq memv modulo remainder negative? | ||
44 | positive? newline not null? number->string string->number number? | ||
45 | open-input-bytevector open-output-bytevector open-input-string | ||
46 | open-output-string or pair? parameterize peek-char peek-u8 port? | ||
47 | procedure? quasiquote quote quotient remainder raise raise-continuable | ||
48 | rational? rationalize read-bytevector read-bytevector! read-char | ||
49 | read-error? read-line read-string read-u8 real? reverse round set! | ||
50 | set-car! set-cdr! square string string->list list->string string->utf8 | ||
51 | utf8->string string->symbol symbol->string string->vector | ||
52 | string-append string-copy string-copy! string-fill! string-for-each | ||
53 | string-length string-map string-ref string-set! string=? string<? | ||
54 | string>? string<=? string>=? string? substring symbol=? symbol? | ||
55 | syntax-error syntax-rules textual-port? truncate truncate/ | ||
56 | truncate-quotient truncate-remainder u8-ready? unless #;unquote | ||
57 | #;unquote-splicing values vector vector-append vector-copy vector-copy! | ||
58 | vector-fill! vector-for-each vector-length vector-map vector-ref | ||
59 | vector-set! vector->list vector->string vector? when | ||
60 | with-exception-handler write-bytevector write-char write-string | ||
61 | write-u8 zero?) | ||
62 | (export case-lambda) | ||
63 | (export char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? | ||
64 | char-ci>? char-downcase char-foldcase char-lower-case? char-numeric? | ||
65 | char-upcase char-upper-case? char-whitespace? digit-value string-ci<=? | ||
66 | string-ci<? string-ci=? string-ci>=? string-ci>? string-downcase | ||
67 | string-foldcase string-upcase) | ||
68 | (export angle imag-part magnitude make-polar make-rectangular real-part) | ||
69 | (export caaaar caaadr caaar caadar caaddr caadr cadaar cadadr cadar caddar | ||
70 | cadddr caddr cdaaar cdaadr cdaar cdadar cdaddr cdadr cddaar cddadr | ||
71 | cddar cdddar cddddr cdddr) | ||
72 | (export environment eval) | ||
73 | (export call-with-input-file call-with-output-file delete-file file-exists? | ||
74 | open-binary-input-file open-binary-output-file open-input-file | ||
75 | open-output-file with-input-from-file with-output-to-file) | ||
76 | (export acos asin atan cos exp finite? infinite? log nan? sin sqrt tan) | ||
77 | (export delay delay-force force make-promise promise?) | ||
78 | (export load) | ||
79 | (export command-line emergency-exit exit get-environment-variable | ||
80 | get-environment-variables) | ||
81 | (export read) | ||
82 | (export interaction-environment) | ||
83 | (export current-jiffy current-second jiffies-per-second) | ||
84 | (export display write write-shared write-simple) | ||
85 | 22 | ||
86 | (include "chicanery.extras.scm")) | 23 | (reexport r7rs) |
24 | (reexport (scheme base)) | ||
25 | (reexport (scheme case-lambda)) | ||
26 | (reexport (scheme char)) | ||
27 | (reexport (scheme complex)) | ||
28 | (reexport (scheme cxr)) | ||
29 | (reexport (scheme eval)) | ||
30 | (reexport (scheme file)) | ||
31 | (reexport (scheme inexact)) | ||
32 | (reexport (scheme lazy)) | ||
33 | (reexport (scheme load)) | ||
34 | (reexport (scheme process-context)) | ||
35 | (reexport (scheme read)) | ||
36 | (reexport (scheme repl)) | ||
37 | (reexport (scheme time)) | ||
38 | (reexport (scheme write)) | ||
39 | (reexport utf8) | ||
40 | |||
41 | (include "extras.scm") | ||
87 | 42 | ||
43 | (register-feature! #:chicanery)) | ||