Skip to content

Commit d57cd9f

Browse files
committed
Implement SRFI 166.
1 parent 011986c commit d57cd9f

File tree

10 files changed

+2311
-0
lines changed

10 files changed

+2311
-0
lines changed

LispKit.xcodeproj/project.pbxproj

+72
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@
8080
CC14F4B01F939486000FB1E0 /* Features.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC14F4AF1F939486000FB1E0 /* Features.swift */; };
8181
CC14F4B21F93A455000FB1E0 /* FeatureRequirement.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC14F4B11F93A455000FB1E0 /* FeatureRequirement.swift */; };
8282
CC14F4B31F93AE04000FB1E0 /* AvlTrees.scm in Copy examples */ = {isa = PBXBuildFile; fileRef = CC14F4AE1F9385BF000FB1E0 /* AvlTrees.scm */; };
83+
CC1867342750E90000B31427 /* pretty.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC1867302750E5D800B31427 /* pretty.sld */; };
84+
CC1867352750E90600B31427 /* color.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC18672E2750E57A00B31427 /* color.sld */; };
85+
CC1867362750E90D00B31427 /* columnar.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC18672F2750E5C300B31427 /* columnar.sld */; };
86+
CC1867372750E91500B31427 /* base.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC18672D2750E4DC00B31427 /* base.sld */; };
87+
CC1867382750E92000B31427 /* unicode.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC1867312750E5E100B31427 /* unicode.sld */; };
88+
CC1867392750E93700B31427 /* 166.sld in Copy pre-installed SRFI libraries */ = {isa = PBXBuildFile; fileRef = CC1867322750E5F600B31427 /* 166.sld */; };
89+
CC18673B2750E97700B31427 /* base.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC18672D2750E4DC00B31427 /* base.sld */; };
90+
CC18673C2750E97C00B31427 /* color.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC18672E2750E57A00B31427 /* color.sld */; };
91+
CC18673D2750E98200B31427 /* columnar.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC18672F2750E5C300B31427 /* columnar.sld */; };
92+
CC18673E2750E98700B31427 /* pretty.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC1867302750E5D800B31427 /* pretty.sld */; };
93+
CC18673F2750E99400B31427 /* unicode.sld in Copy pre-installed LispKit library: SRFI 166 */ = {isa = PBXBuildFile; fileRef = CC1867312750E5E100B31427 /* unicode.sld */; };
94+
CC1867402750E9A400B31427 /* 166.sld in Copy pre-installed SRFI libraries */ = {isa = PBXBuildFile; fileRef = CC1867322750E5F600B31427 /* 166.sld */; };
95+
CC1867422750EAC300B31427 /* SRFI-166.scm in Copy tests */ = {isa = PBXBuildFile; fileRef = CC1867412750E9F900B31427 /* SRFI-166.scm */; };
96+
CC1867432750EADC00B31427 /* SRFI-166.scm in Copy tests */ = {isa = PBXBuildFile; fileRef = CC1867412750E9F900B31427 /* SRFI-166.scm */; };
8397
CC1AAE3B1CC3CF0F00D1806F /* LispKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCAD52BA1C48403800DBD8EE /* LispKit.framework */; };
8498
CC1AAE3C1CC3CF0F00D1806F /* LispKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CCAD52BA1C48403800DBD8EE /* LispKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
8599
CC1D6CBA258CCE1A00D36645 /* EditDistance.scm in Copy examples */ = {isa = PBXBuildFile; fileRef = CC1D6CB9258CCCFF00D36645 /* EditDistance.scm */; };
@@ -1018,6 +1032,7 @@
10181032
dstPath = Root/LispKit/Tests;
10191033
dstSubfolderSpec = 7;
10201034
files = (
1035+
CC1867422750EAC300B31427 /* SRFI-166.scm in Copy tests */,
10211036
CCBDF734274AEB0800635B5C /* SRFI-227.scm in Copy tests */,
10221037
CCBDF72E2749B23400635B5C /* SRFI-229.scm in Copy tests */,
10231038
CCD4A6F826EDFC6500BEE906 /* SRFI-217.scm in Copy tests */,
@@ -1055,6 +1070,36 @@
10551070
name = "Copy tests";
10561071
runOnlyForDeploymentPostprocessing = 0;
10571072
};
1073+
CC1867332750E8CF00B31427 /* Copy pre-installed LispKit library: SRFI 166 */ = {
1074+
isa = PBXCopyFilesBuildPhase;
1075+
buildActionMask = 2147483647;
1076+
dstPath = Root/LispKit/Libraries/srfi/166;
1077+
dstSubfolderSpec = 7;
1078+
files = (
1079+
CC1867382750E92000B31427 /* unicode.sld in Copy pre-installed LispKit library: SRFI 166 */,
1080+
CC1867372750E91500B31427 /* base.sld in Copy pre-installed LispKit library: SRFI 166 */,
1081+
CC1867362750E90D00B31427 /* columnar.sld in Copy pre-installed LispKit library: SRFI 166 */,
1082+
CC1867352750E90600B31427 /* color.sld in Copy pre-installed LispKit library: SRFI 166 */,
1083+
CC1867342750E90000B31427 /* pretty.sld in Copy pre-installed LispKit library: SRFI 166 */,
1084+
);
1085+
name = "Copy pre-installed LispKit library: SRFI 166";
1086+
runOnlyForDeploymentPostprocessing = 0;
1087+
};
1088+
CC18673A2750E94A00B31427 /* Copy pre-installed LispKit library: SRFI 166 */ = {
1089+
isa = PBXCopyFilesBuildPhase;
1090+
buildActionMask = 2147483647;
1091+
dstPath = Root/LispKit/Libraries/srfi/166;
1092+
dstSubfolderSpec = 7;
1093+
files = (
1094+
CC18673F2750E99400B31427 /* unicode.sld in Copy pre-installed LispKit library: SRFI 166 */,
1095+
CC18673E2750E98700B31427 /* pretty.sld in Copy pre-installed LispKit library: SRFI 166 */,
1096+
CC18673D2750E98200B31427 /* columnar.sld in Copy pre-installed LispKit library: SRFI 166 */,
1097+
CC18673C2750E97C00B31427 /* color.sld in Copy pre-installed LispKit library: SRFI 166 */,
1098+
CC18673B2750E97700B31427 /* base.sld in Copy pre-installed LispKit library: SRFI 166 */,
1099+
);
1100+
name = "Copy pre-installed LispKit library: SRFI 166";
1101+
runOnlyForDeploymentPostprocessing = 0;
1102+
};
10581103
CC1AAE3F1CC3CF0F00D1806F /* Embed Frameworks */ = {
10591104
isa = PBXCopyFilesBuildPhase;
10601105
buildActionMask = 8;
@@ -1538,6 +1583,7 @@
15381583
dstPath = Root/LispKit/Libraries/srfi;
15391584
dstSubfolderSpec = 7;
15401585
files = (
1586+
CC1867392750E93700B31427 /* 166.sld in Copy pre-installed SRFI libraries */,
15411587
CCBDF731274ADF7000635B5C /* 227.sld in Copy pre-installed SRFI libraries */,
15421588
CCBDF72B2749B0C100635B5C /* 229.sld in Copy pre-installed SRFI libraries */,
15431589
CCD4A6F726EDFC5800BEE906 /* 217.sld in Copy pre-installed SRFI libraries */,
@@ -1640,6 +1686,7 @@
16401686
dstPath = Root/LispKit/Libraries/srfi;
16411687
dstSubfolderSpec = 7;
16421688
files = (
1689+
CC1867402750E9A400B31427 /* 166.sld in Copy pre-installed SRFI libraries */,
16431690
CCBDF732274ADF8B00635B5C /* 227.sld in Copy pre-installed SRFI libraries */,
16441691
CCBDF72C2749B0DA00635B5C /* 229.sld in Copy pre-installed SRFI libraries */,
16451692
CCD4A6F926EDFC7200BEE906 /* 217.sld in Copy pre-installed SRFI libraries */,
@@ -1984,6 +2031,7 @@
19842031
dstPath = Root/LispKit/Tests;
19852032
dstSubfolderSpec = 7;
19862033
files = (
2034+
CC1867432750EADC00B31427 /* SRFI-166.scm in Copy tests */,
19872035
CCBDF735274AEB2900635B5C /* SRFI-227.scm in Copy tests */,
19882036
CCBDF72F2749B24900635B5C /* SRFI-229.scm in Copy tests */,
19892037
CCD4A6FA26EDFC8300BEE906 /* SRFI-217.scm in Copy tests */,
@@ -2272,6 +2320,13 @@
22722320
CC14F4AE1F9385BF000FB1E0 /* AvlTrees.scm */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = text; path = AvlTrees.scm; sourceTree = "<group>"; tabWidth = 2; };
22732321
CC14F4AF1F939486000FB1E0 /* Features.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Features.swift; sourceTree = "<group>"; };
22742322
CC14F4B11F93A455000FB1E0 /* FeatureRequirement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureRequirement.swift; sourceTree = "<group>"; };
2323+
CC18672D2750E4DC00B31427 /* base.sld */ = {isa = PBXFileReference; lastKnownFileType = text; path = base.sld; sourceTree = "<group>"; };
2324+
CC18672E2750E57A00B31427 /* color.sld */ = {isa = PBXFileReference; lastKnownFileType = text; path = color.sld; sourceTree = "<group>"; };
2325+
CC18672F2750E5C300B31427 /* columnar.sld */ = {isa = PBXFileReference; lastKnownFileType = text; path = columnar.sld; sourceTree = "<group>"; };
2326+
CC1867302750E5D800B31427 /* pretty.sld */ = {isa = PBXFileReference; lastKnownFileType = text; path = pretty.sld; sourceTree = "<group>"; };
2327+
CC1867312750E5E100B31427 /* unicode.sld */ = {isa = PBXFileReference; lastKnownFileType = text; path = unicode.sld; sourceTree = "<group>"; };
2328+
CC1867322750E5F600B31427 /* 166.sld */ = {isa = PBXFileReference; lastKnownFileType = text; path = 166.sld; sourceTree = "<group>"; };
2329+
CC1867412750E9F900B31427 /* SRFI-166.scm */ = {isa = PBXFileReference; lastKnownFileType = text; path = "SRFI-166.scm"; sourceTree = "<group>"; };
22752330
CC1D6CB9258CCCFF00D36645 /* EditDistance.scm */ = {isa = PBXFileReference; lastKnownFileType = text; path = EditDistance.scm; sourceTree = "<group>"; };
22762331
CC1D6CBD258CDE3700D36645 /* 209.sld */ = {isa = PBXFileReference; lastKnownFileType = text; path = 209.sld; sourceTree = "<group>"; };
22772332
CC1D6CC1258CDF0000D36645 /* SRFI-209.scm */ = {isa = PBXFileReference; lastKnownFileType = text; path = "SRFI-209.scm"; sourceTree = "<group>"; };
@@ -2811,6 +2866,7 @@
28112866
CC08F42E25BCF14C0056C92C /* SRFI-154.scm */,
28122867
CC08F43825BCFCAB0056C92C /* SRFI-155.scm */,
28132868
CC4A7DC8225A344300936034 /* SRFI-165.scm */,
2869+
CC1867412750E9F900B31427 /* SRFI-166.scm */,
28142870
CCF602E923A0F8F800087740 /* SRFI-167.scm */,
28152871
CC38528D23140F26001D5E56 /* SRFI-173.scm */,
28162872
CC5E53092358359900C72CE2 /* SRFI-174.scm */,
@@ -2885,6 +2941,18 @@
28852941
path = Code;
28862942
sourceTree = "<group>";
28872943
};
2944+
CC18672C2750E1C700B31427 /* 166 */ = {
2945+
isa = PBXGroup;
2946+
children = (
2947+
CC18672D2750E4DC00B31427 /* base.sld */,
2948+
CC18672E2750E57A00B31427 /* color.sld */,
2949+
CC18672F2750E5C300B31427 /* columnar.sld */,
2950+
CC1867302750E5D800B31427 /* pretty.sld */,
2951+
CC1867312750E5E100B31427 /* unicode.sld */,
2952+
);
2953+
path = 166;
2954+
sourceTree = "<group>";
2955+
};
28882956
CC240E8A24FB144500FF6D0F /* sxml */ = {
28892957
isa = PBXGroup;
28902958
children = (
@@ -3136,6 +3204,8 @@
31363204
CC1EA5CA214EEF41006BBE7E /* 161.sld */,
31373205
CCC9516E2426B1E100FC915F /* 162.sld */,
31383206
CC4A7DC6225A021E00936034 /* 165.sld */,
3207+
CC1867322750E5F600B31427 /* 166.sld */,
3208+
CC18672C2750E1C700B31427 /* 166 */,
31393209
CCF602E523A0F64600087740 /* 167 */,
31403210
CC38528C23140CC2001D5E56 /* 173.sld */,
31413211
CC5E530723579CF200C72CE2 /* 174.sld */,
@@ -3778,6 +3848,7 @@
37783848
CC2C73DA21A1FFB200B18661 /* Copy pre-installed LispKit library: SRFI 69 */,
37793849
CC48EBD21F3E5B9900233FA9 /* Copy pre-installed LispKit library: SRFI 135 */,
37803850
CC4A7DC02259741100936034 /* Copy pre-installed LispKit library: SRFI 146 */,
3851+
CC1867332750E8CF00B31427 /* Copy pre-installed LispKit library: SRFI 166 */,
37813852
CCF602EB23A0FA7000087740 /* Copy pre-installed LispKit library: SRFI 167 */,
37823853
CC5848001E50ABE100BE6497 /* Copy pre-installed LispKit libraries */,
37833854
CC624CD727374D71005F15B3 /* Copy pre-installed LispKit library: LispKit Math */,
@@ -3842,6 +3913,7 @@
38423913
CCC48D7625E97F0500D082AD /* Copy pre-installed LispKit library: SRFI 69 */,
38433914
CCC48D7B25E97F8100D082AD /* Copy pre-installed LispKit library: SRFI 135 */,
38443915
CCC48D8025E97FBC00D082AD /* Copy pre-installed LispKit library: SRFI 146 */,
3916+
CC18673A2750E94A00B31427 /* Copy pre-installed LispKit library: SRFI 166 */,
38453917
CCC48D8525E97FF500D082AD /* Copy pre-installed LispKit library: SRFI 167 */,
38463918
CCC48D8C25E9803400D082AD /* Copy pre-installed LispKit libraries */,
38473919
CC624CD927374E7D005F15B3 /* Copy pre-installed LispKit library: LispKit Math */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
;;; SRFI 166
2+
;;; Monadic Formatting
3+
;;;
4+
;;; A library of procedures for formatting Scheme objects to text in various ways, and
5+
;;; for easily concatenating, composing and extending these formatters efficiently
6+
;;; without resorting to capturing and manipulating intermediate strings. This SRFI is
7+
;;; an updated version of SRFI 159, primarily with the difference that state variables
8+
;;; are hygienic.
9+
;;;
10+
;;; This implementation is lacking support for pretty printing. There are also issues
11+
;;; related to writing shared/recursive structures.
12+
;;;
13+
;;; Copyright © 2020 Marc Nieper-Wißkirchen. All rights reserved.
14+
;;;
15+
;;; Permission is hereby granted, free of charge, to any person obtaining a copy of this
16+
;;; software and associated documentation files (the "Software"), to deal in the Software
17+
;;; without restriction, including without limitation the rights to use, copy, modify, merge,
18+
;;; publish, distribute, sublicense, and/or sell copies of the Software, and to permit
19+
;;; persons to whom the Software is furnished to do so, subject to the following conditions:
20+
;;;
21+
;;; The above copyright notice and this permission notice shall be included in all copies or
22+
;;; substantial portions of the Software.
23+
;;;
24+
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
25+
;;; INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
26+
;;; PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27+
;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
28+
;;; CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
29+
;;; OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30+
;;;
31+
;;; LispKit Port:
32+
;;; Copyright © 2021 Matthias Zenger. All rights reserved.
33+
34+
(define-library (srfi 166)
35+
36+
(export show
37+
displayed
38+
written
39+
written-shared
40+
written-simply
41+
escaped
42+
maybe-escaped
43+
numeric
44+
numeric/comma
45+
numeric/si
46+
numeric/fitted
47+
nl
48+
fl
49+
space-to
50+
tab-to
51+
nothing
52+
each
53+
each-in-list
54+
joined
55+
joined/prefix
56+
joined/suffix
57+
joined/last
58+
joined/dot
59+
joined/range
60+
padded
61+
padded/right
62+
padded/both
63+
trimmed
64+
trimmed/right
65+
trimmed/both
66+
trimmed/lazy
67+
fitted
68+
fitted/right
69+
fitted/both
70+
output-default
71+
fn
72+
with
73+
with!
74+
forked
75+
call-with-output
76+
port
77+
row
78+
col
79+
width
80+
output
81+
writer
82+
string-width
83+
pad-char
84+
ellipsis
85+
radix
86+
precision
87+
decimal-sep
88+
decimal-align
89+
sign-rule
90+
comma-sep
91+
comma-rule
92+
word-separator?
93+
ambiguous-is-wide?
94+
pretty
95+
pretty-shared
96+
pretty-simply
97+
pretty-color
98+
columnar tabular wrapped wrapped/list wrapped/char
99+
justified from-file line-numbers
100+
;; show-columns
101+
as-unicode unicode-terminal-width unicode-terminal-width/wide
102+
upcased downcased
103+
as-red as-blue as-green as-cyan as-yellow
104+
as-magenta as-white as-black
105+
as-bold as-underline
106+
as-color as-true-color)
107+
108+
(import (srfi 166 base)
109+
(srfi 166 color)
110+
(srfi 166 columnar)
111+
(srfi 166 unicode)
112+
(srfi 166 pretty))
113+
)

0 commit comments

Comments
 (0)