Text alignment functions are no longer builtin

This commit is contained in:
Paul Chiusano 2021-04-14 15:29:49 -05:00
parent 4704cbf4f2
commit 73b9eb1424
11 changed files with 400 additions and 408 deletions

View File

@ -382,9 +382,6 @@ builtinsSrc =
, B "Text.drop" $ nat --> text --> text
, B "Text.size" $ text --> nat
, B "Text.repeat" $ nat --> text --> text
, B "Text.alignLeftWith" $ nat --> char --> text --> text
, B "Text.alignRightWith" $ nat --> char --> text --> text
, B "Text.alignCenterWith" $ nat --> char --> text --> text
, B "Text.==" $ text --> text --> boolean
, D "Text.!=" $ text --> text --> boolean
, B "Text.<=" $ text --> text --> boolean
@ -398,6 +395,7 @@ builtinsSrc =
, B "Text.toUtf8" $ text --> bytes
, B "Text.fromUtf8.impl.v3" $ bytes --> eithert failure text
, B "Char.toNat" $ char --> nat
, B "Char.toText" $ char --> text
, B "Char.fromNat" $ nat --> char
, B "Bytes.empty" bytes

View File

@ -1004,6 +1004,19 @@ boxToBool = inBx arg result
where
(arg, result) = fresh2
-- Nat -> c
-- Works for an type that's packed into a word, just
-- pass `wordDirect Ty.natRef`, `wordDirect Ty.floatRef`
-- etc
wordDirect :: Reference -> ForeignOp
wordDirect wordType instr
= ([BX],)
. TAbss [b1]
. unbox b1 wordType ub1
$ TFOp instr [ub1]
where
(b1,ub1) = fresh2
-- Nat -> a -> c
-- Works for an type that's packed into a word, just
-- pass `wordBoxDirect Ty.natRef`, `wordBoxDirect Ty.floatRef`
@ -1017,20 +1030,6 @@ wordBoxDirect wordType instr
where
(b1,b2,ub1) = fresh3
-- Nat -> Char -> a -> c
-- Works for any types that are packed into a word, not just `Nat`.
-- Example: wordWordBoxDirect Ty.natRef Ty.charRef
-- wordWordBoxDirect Ty.floatRef Ty.natRef
wordWordBoxDirect :: Reference -> Reference -> ForeignOp
wordWordBoxDirect wordType1 wordType2 instr
= ([BX,BX,BX],)
. TAbss [b1,b2,b3]
. unbox b1 wordType1 ub1
. unbox b2 wordType2 ub2
$ TFOp instr [ub1,ub2,b3]
where
(b1,b2,b3,ub1,ub2) = fresh5
-- a -> b -> c
boxBoxDirect :: ForeignOp
boxBoxDirect instr
@ -1498,21 +1497,12 @@ declareForeigns = do
declareForeign "MVar.tryRead.impl.v3" boxToEFBox
. mkForeignIOF $ \(mv :: MVar Closure) -> tryReadMVar mv
declareForeign "Char.toText" (wordDirect Ty.charRef) . mkForeign $
\(ch :: Char) -> pure (Text.singleton ch)
declareForeign "Text.repeat" (wordBoxDirect Ty.natRef) . mkForeign $
\(n :: Word64, txt :: Text) -> pure (Text.replicate (fromIntegral n) txt)
declareForeign "Text.alignLeftWith" (wordWordBoxDirect Ty.natRef Ty.charRef) . mkForeign $
\(n :: Word64, padChar :: Char, txt :: Text) ->
pure (Text.justifyLeft (fromIntegral n) padChar txt)
declareForeign "Text.alignRightWith" (wordWordBoxDirect Ty.natRef Ty.charRef) . mkForeign $
\(n :: Word64, padChar :: Char, txt :: Text) ->
pure (Text.justifyRight (fromIntegral n) padChar txt)
declareForeign "Text.alignCenterWith" (wordWordBoxDirect Ty.natRef Ty.charRef) . mkForeign $
\(n :: Word64, padChar :: Char, txt :: Text) ->
pure (Text.center (fromIntegral n) padChar txt)
declareForeign "Text.toUtf8" boxDirect . mkForeign
$ pure . Bytes.fromArray . encodeUtf8

View File

@ -957,6 +957,18 @@ List.map f as =
h +: t -> go (acc :+ f h) t
go [] as
Text.alignRightWith : Nat -> Char -> Text -> Text
Text.alignRightWith w padChar txt =
rem = drop w (Text.size txt)
if rem == 0 then txt
else Text.repeat rem (Char.toText padChar) Text.++ txt
Text.alignLeftWith : Nat -> Char -> Text -> Text
Text.alignLeftWith w padChar txt =
rem = drop w (Text.size txt)
if rem == 0 then txt
else txt Text.++ Text.repeat rem (Char.toText padChar)
Either.mapRight : (a -> b) -> Either e a -> Either e b
Either.mapRight f = cases
Right a -> Right (f a)

View File

@ -167,8 +167,6 @@ test> Text.tests.repeat =
test> Text.tests.alignment =
checks [
Text.alignCenterWith 11 ?- "o" == "-----o-----",
Text.alignCenterWith 11 ?\s "a" == " a ",
Text.alignLeftWith 5 ?\s "a" == "a ",
Text.alignRightWith 5 ?_ "ababa" == "ababa",
Text.alignRightWith 5 ?_ "ab" == "___ab"

View File

@ -159,8 +159,6 @@ test> Text.tests.repeat =
test> Text.tests.alignment =
checks [
Text.alignCenterWith 11 ?- "o" == "-----o-----",
Text.alignCenterWith 11 ?\s "a" == " a ",
Text.alignLeftWith 5 ?\s "a" == "a ",
Text.alignRightWith 5 ?_ "ababa" == "ababa",
Text.alignRightWith 5 ?_ "ab" == "___ab"

View File

@ -43,388 +43,386 @@ Let's try it!
23. builtin type Char
24. Char.fromNat : Nat -> Char
25. Char.toNat : Char -> Nat
26. builtin type Code
27. Code.cache_ : [(Term, Code)] ->{IO} [Term]
28. Code.dependencies : Code -> [Term]
29. Code.deserialize : Bytes -> Either Text Code
30. Code.isMissing : Term ->{IO} Boolean
31. Code.lookup : Term ->{IO} Optional Code
32. Code.serialize : Code -> Bytes
33. Debug.watch : Text -> a -> a
34. unique type Doc
35. Doc.Blob : Text -> Doc
36. Doc.Evaluate : Term -> Doc
37. Doc.Join : [Doc] -> Doc
38. Doc.Link : Link -> Doc
39. Doc.Signature : Term -> Doc
40. Doc.Source : Link -> Doc
41. type Either a b
42. Either.Left : a -> Either a b
43. Either.Right : b -> Either a b
44. builtin type Float
45. Float.* : Float -> Float -> Float
46. Float.+ : Float -> Float -> Float
47. Float.- : Float -> Float -> Float
48. Float./ : Float -> Float -> Float
49. Float.abs : Float -> Float
50. Float.acos : Float -> Float
51. Float.acosh : Float -> Float
52. Float.asin : Float -> Float
53. Float.asinh : Float -> Float
54. Float.atan : Float -> Float
55. Float.atan2 : Float -> Float -> Float
56. Float.atanh : Float -> Float
57. Float.ceiling : Float -> Int
58. Float.cos : Float -> Float
59. Float.cosh : Float -> Float
60. Float.eq : Float -> Float -> Boolean
61. Float.exp : Float -> Float
62. Float.floor : Float -> Int
63. Float.fromText : Text -> Optional Float
64. Float.gt : Float -> Float -> Boolean
65. Float.gteq : Float -> Float -> Boolean
66. Float.log : Float -> Float
67. Float.logBase : Float -> Float -> Float
68. Float.lt : Float -> Float -> Boolean
69. Float.lteq : Float -> Float -> Boolean
70. Float.max : Float -> Float -> Float
71. Float.min : Float -> Float -> Float
72. Float.pow : Float -> Float -> Float
73. Float.round : Float -> Int
74. Float.sin : Float -> Float
75. Float.sinh : Float -> Float
76. Float.sqrt : Float -> Float
77. Float.tan : Float -> Float
78. Float.tanh : Float -> Float
79. Float.toText : Float -> Text
80. Float.truncate : Float -> Int
81. builtin type Int
82. Int.* : Int -> Int -> Int
83. Int.+ : Int -> Int -> Int
84. Int.- : Int -> Int -> Int
85. Int./ : Int -> Int -> Int
86. Int.and : Int -> Int -> Int
87. Int.complement : Int -> Int
88. Int.eq : Int -> Int -> Boolean
89. Int.fromText : Text -> Optional Int
90. Int.gt : Int -> Int -> Boolean
91. Int.gteq : Int -> Int -> Boolean
92. Int.increment : Int -> Int
93. Int.isEven : Int -> Boolean
94. Int.isOdd : Int -> Boolean
95. Int.leadingZeros : Int -> Nat
96. Int.lt : Int -> Int -> Boolean
97. Int.lteq : Int -> Int -> Boolean
98. Int.mod : Int -> Int -> Int
99. Int.negate : Int -> Int
100. Int.or : Int -> Int -> Int
101. Int.popCount : Int -> Nat
102. Int.pow : Int -> Nat -> Int
103. Int.shiftLeft : Int -> Nat -> Int
104. Int.shiftRight : Int -> Nat -> Int
105. Int.signum : Int -> Int
106. Int.toFloat : Int -> Float
107. Int.toText : Int -> Text
108. Int.trailingZeros : Int -> Nat
109. Int.truncate0 : Int -> Nat
110. Int.xor : Int -> Int -> Int
111. unique type IsPropagated
112. IsPropagated.IsPropagated : IsPropagated
113. unique type IsTest
114. IsTest.IsTest : IsTest
115. unique type Link
116. builtin type Link.Term
117. Link.Term : Term -> Link
118. builtin type Link.Type
119. Link.Type : Type -> Link
120. builtin type List
121. List.++ : [a] -> [a] -> [a]
122. List.+: : a -> [a] -> [a]
123. List.:+ : [a] -> a -> [a]
124. List.at : Nat -> [a] -> Optional a
125. List.cons : a -> [a] -> [a]
126. List.drop : Nat -> [a] -> [a]
127. List.empty : [a]
128. List.size : [a] -> Nat
129. List.snoc : [a] -> a -> [a]
130. List.take : Nat -> [a] -> [a]
131. builtin type Nat
132. Nat.* : Nat -> Nat -> Nat
133. Nat.+ : Nat -> Nat -> Nat
134. Nat./ : Nat -> Nat -> Nat
135. Nat.and : Nat -> Nat -> Nat
136. Nat.complement : Nat -> Nat
137. Nat.drop : Nat -> Nat -> Nat
138. Nat.eq : Nat -> Nat -> Boolean
139. Nat.fromText : Text -> Optional Nat
140. Nat.gt : Nat -> Nat -> Boolean
141. Nat.gteq : Nat -> Nat -> Boolean
142. Nat.increment : Nat -> Nat
143. Nat.isEven : Nat -> Boolean
144. Nat.isOdd : Nat -> Boolean
145. Nat.leadingZeros : Nat -> Nat
146. Nat.lt : Nat -> Nat -> Boolean
147. Nat.lteq : Nat -> Nat -> Boolean
148. Nat.mod : Nat -> Nat -> Nat
149. Nat.or : Nat -> Nat -> Nat
150. Nat.popCount : Nat -> Nat
151. Nat.pow : Nat -> Nat -> Nat
152. Nat.shiftLeft : Nat -> Nat -> Nat
153. Nat.shiftRight : Nat -> Nat -> Nat
154. Nat.sub : Nat -> Nat -> Int
155. Nat.toFloat : Nat -> Float
156. Nat.toInt : Nat -> Int
157. Nat.toText : Nat -> Text
158. Nat.trailingZeros : Nat -> Nat
159. Nat.xor : Nat -> Nat -> Nat
160. type Optional a
161. Optional.None : Optional a
162. Optional.Some : a -> Optional a
163. builtin type Request
164. type SeqView a b
165. SeqView.VElem : a -> b -> SeqView a b
166. SeqView.VEmpty : SeqView a b
167. unique type Test.Result
168. Test.Result.Fail : Text -> Result
169. Test.Result.Ok : Text -> Result
170. builtin type Text
171. Text.!= : Text -> Text -> Boolean
172. Text.++ : Text -> Text -> Text
173. Text.alignCenterWith : Nat -> Char -> Text -> Text
174. Text.alignLeftWith : Nat -> Char -> Text -> Text
175. Text.alignRightWith : Nat -> Char -> Text -> Text
176. Text.drop : Nat -> Text -> Text
177. Text.empty : Text
178. Text.eq : Text -> Text -> Boolean
179. Text.fromCharList : [Char] -> Text
180. Text.fromUtf8.impl : Bytes -> Either Failure Text
181. Text.gt : Text -> Text -> Boolean
182. Text.gteq : Text -> Text -> Boolean
183. Text.lt : Text -> Text -> Boolean
184. Text.lteq : Text -> Text -> Boolean
185. Text.repeat : Nat -> Text -> Text
186. Text.size : Text -> Nat
187. Text.take : Nat -> Text -> Text
188. Text.toCharList : Text -> [Char]
189. Text.toUtf8 : Text -> Bytes
190. Text.uncons : Text -> Optional (Char, Text)
191. Text.unsnoc : Text -> Optional (Text, Char)
192. type Tuple a b
193. Tuple.Cons : a -> b -> Tuple a b
194. type Unit
195. Unit.Unit : ()
196. Universal.< : a -> a -> Boolean
197. Universal.<= : a -> a -> Boolean
198. Universal.== : a -> a -> Boolean
199. Universal.> : a -> a -> Boolean
200. Universal.>= : a -> a -> Boolean
201. Universal.compare : a -> a -> Int
202. builtin type Value
203. Value.dependencies : Value -> [Term]
204. Value.deserialize : Bytes -> Either Text Value
205. Value.load : Value ->{IO} Either [Term] a
206. Value.serialize : Value -> Bytes
207. Value.value : a -> Value
208. bug : a -> b
209. builtin type crypto.HashAlgorithm
210. crypto.HashAlgorithm.Blake2b_256 : HashAlgorithm
211. crypto.HashAlgorithm.Blake2b_512 : HashAlgorithm
212. crypto.HashAlgorithm.Blake2s_256 : HashAlgorithm
213. crypto.HashAlgorithm.Sha2_256 : HashAlgorithm
214. crypto.HashAlgorithm.Sha2_512 : HashAlgorithm
215. crypto.HashAlgorithm.Sha3_256 : HashAlgorithm
216. crypto.HashAlgorithm.Sha3_512 : HashAlgorithm
217. crypto.hash : HashAlgorithm -> a -> Bytes
218. crypto.hashBytes : HashAlgorithm -> Bytes -> Bytes
219. crypto.hmac : HashAlgorithm -> Bytes -> a -> Bytes
220. crypto.hmacBytes : HashAlgorithm
26. Char.toText : Char -> Text
27. builtin type Code
28. Code.cache_ : [(Term, Code)] ->{IO} [Term]
29. Code.dependencies : Code -> [Term]
30. Code.deserialize : Bytes -> Either Text Code
31. Code.isMissing : Term ->{IO} Boolean
32. Code.lookup : Term ->{IO} Optional Code
33. Code.serialize : Code -> Bytes
34. Debug.watch : Text -> a -> a
35. unique type Doc
36. Doc.Blob : Text -> Doc
37. Doc.Evaluate : Term -> Doc
38. Doc.Join : [Doc] -> Doc
39. Doc.Link : Link -> Doc
40. Doc.Signature : Term -> Doc
41. Doc.Source : Link -> Doc
42. type Either a b
43. Either.Left : a -> Either a b
44. Either.Right : b -> Either a b
45. builtin type Float
46. Float.* : Float -> Float -> Float
47. Float.+ : Float -> Float -> Float
48. Float.- : Float -> Float -> Float
49. Float./ : Float -> Float -> Float
50. Float.abs : Float -> Float
51. Float.acos : Float -> Float
52. Float.acosh : Float -> Float
53. Float.asin : Float -> Float
54. Float.asinh : Float -> Float
55. Float.atan : Float -> Float
56. Float.atan2 : Float -> Float -> Float
57. Float.atanh : Float -> Float
58. Float.ceiling : Float -> Int
59. Float.cos : Float -> Float
60. Float.cosh : Float -> Float
61. Float.eq : Float -> Float -> Boolean
62. Float.exp : Float -> Float
63. Float.floor : Float -> Int
64. Float.fromText : Text -> Optional Float
65. Float.gt : Float -> Float -> Boolean
66. Float.gteq : Float -> Float -> Boolean
67. Float.log : Float -> Float
68. Float.logBase : Float -> Float -> Float
69. Float.lt : Float -> Float -> Boolean
70. Float.lteq : Float -> Float -> Boolean
71. Float.max : Float -> Float -> Float
72. Float.min : Float -> Float -> Float
73. Float.pow : Float -> Float -> Float
74. Float.round : Float -> Int
75. Float.sin : Float -> Float
76. Float.sinh : Float -> Float
77. Float.sqrt : Float -> Float
78. Float.tan : Float -> Float
79. Float.tanh : Float -> Float
80. Float.toText : Float -> Text
81. Float.truncate : Float -> Int
82. builtin type Int
83. Int.* : Int -> Int -> Int
84. Int.+ : Int -> Int -> Int
85. Int.- : Int -> Int -> Int
86. Int./ : Int -> Int -> Int
87. Int.and : Int -> Int -> Int
88. Int.complement : Int -> Int
89. Int.eq : Int -> Int -> Boolean
90. Int.fromText : Text -> Optional Int
91. Int.gt : Int -> Int -> Boolean
92. Int.gteq : Int -> Int -> Boolean
93. Int.increment : Int -> Int
94. Int.isEven : Int -> Boolean
95. Int.isOdd : Int -> Boolean
96. Int.leadingZeros : Int -> Nat
97. Int.lt : Int -> Int -> Boolean
98. Int.lteq : Int -> Int -> Boolean
99. Int.mod : Int -> Int -> Int
100. Int.negate : Int -> Int
101. Int.or : Int -> Int -> Int
102. Int.popCount : Int -> Nat
103. Int.pow : Int -> Nat -> Int
104. Int.shiftLeft : Int -> Nat -> Int
105. Int.shiftRight : Int -> Nat -> Int
106. Int.signum : Int -> Int
107. Int.toFloat : Int -> Float
108. Int.toText : Int -> Text
109. Int.trailingZeros : Int -> Nat
110. Int.truncate0 : Int -> Nat
111. Int.xor : Int -> Int -> Int
112. unique type IsPropagated
113. IsPropagated.IsPropagated : IsPropagated
114. unique type IsTest
115. IsTest.IsTest : IsTest
116. unique type Link
117. builtin type Link.Term
118. Link.Term : Term -> Link
119. builtin type Link.Type
120. Link.Type : Type -> Link
121. builtin type List
122. List.++ : [a] -> [a] -> [a]
123. List.+: : a -> [a] -> [a]
124. List.:+ : [a] -> a -> [a]
125. List.at : Nat -> [a] -> Optional a
126. List.cons : a -> [a] -> [a]
127. List.drop : Nat -> [a] -> [a]
128. List.empty : [a]
129. List.size : [a] -> Nat
130. List.snoc : [a] -> a -> [a]
131. List.take : Nat -> [a] -> [a]
132. builtin type Nat
133. Nat.* : Nat -> Nat -> Nat
134. Nat.+ : Nat -> Nat -> Nat
135. Nat./ : Nat -> Nat -> Nat
136. Nat.and : Nat -> Nat -> Nat
137. Nat.complement : Nat -> Nat
138. Nat.drop : Nat -> Nat -> Nat
139. Nat.eq : Nat -> Nat -> Boolean
140. Nat.fromText : Text -> Optional Nat
141. Nat.gt : Nat -> Nat -> Boolean
142. Nat.gteq : Nat -> Nat -> Boolean
143. Nat.increment : Nat -> Nat
144. Nat.isEven : Nat -> Boolean
145. Nat.isOdd : Nat -> Boolean
146. Nat.leadingZeros : Nat -> Nat
147. Nat.lt : Nat -> Nat -> Boolean
148. Nat.lteq : Nat -> Nat -> Boolean
149. Nat.mod : Nat -> Nat -> Nat
150. Nat.or : Nat -> Nat -> Nat
151. Nat.popCount : Nat -> Nat
152. Nat.pow : Nat -> Nat -> Nat
153. Nat.shiftLeft : Nat -> Nat -> Nat
154. Nat.shiftRight : Nat -> Nat -> Nat
155. Nat.sub : Nat -> Nat -> Int
156. Nat.toFloat : Nat -> Float
157. Nat.toInt : Nat -> Int
158. Nat.toText : Nat -> Text
159. Nat.trailingZeros : Nat -> Nat
160. Nat.xor : Nat -> Nat -> Nat
161. type Optional a
162. Optional.None : Optional a
163. Optional.Some : a -> Optional a
164. builtin type Request
165. type SeqView a b
166. SeqView.VElem : a -> b -> SeqView a b
167. SeqView.VEmpty : SeqView a b
168. unique type Test.Result
169. Test.Result.Fail : Text -> Result
170. Test.Result.Ok : Text -> Result
171. builtin type Text
172. Text.!= : Text -> Text -> Boolean
173. Text.++ : Text -> Text -> Text
174. Text.drop : Nat -> Text -> Text
175. Text.empty : Text
176. Text.eq : Text -> Text -> Boolean
177. Text.fromCharList : [Char] -> Text
178. Text.fromUtf8.impl : Bytes -> Either Failure Text
179. Text.gt : Text -> Text -> Boolean
180. Text.gteq : Text -> Text -> Boolean
181. Text.lt : Text -> Text -> Boolean
182. Text.lteq : Text -> Text -> Boolean
183. Text.repeat : Nat -> Text -> Text
184. Text.size : Text -> Nat
185. Text.take : Nat -> Text -> Text
186. Text.toCharList : Text -> [Char]
187. Text.toUtf8 : Text -> Bytes
188. Text.uncons : Text -> Optional (Char, Text)
189. Text.unsnoc : Text -> Optional (Text, Char)
190. type Tuple a b
191. Tuple.Cons : a -> b -> Tuple a b
192. type Unit
193. Unit.Unit : ()
194. Universal.< : a -> a -> Boolean
195. Universal.<= : a -> a -> Boolean
196. Universal.== : a -> a -> Boolean
197. Universal.> : a -> a -> Boolean
198. Universal.>= : a -> a -> Boolean
199. Universal.compare : a -> a -> Int
200. builtin type Value
201. Value.dependencies : Value -> [Term]
202. Value.deserialize : Bytes -> Either Text Value
203. Value.load : Value ->{IO} Either [Term] a
204. Value.serialize : Value -> Bytes
205. Value.value : a -> Value
206. bug : a -> b
207. builtin type crypto.HashAlgorithm
208. crypto.HashAlgorithm.Blake2b_256 : HashAlgorithm
209. crypto.HashAlgorithm.Blake2b_512 : HashAlgorithm
210. crypto.HashAlgorithm.Blake2s_256 : HashAlgorithm
211. crypto.HashAlgorithm.Sha2_256 : HashAlgorithm
212. crypto.HashAlgorithm.Sha2_512 : HashAlgorithm
213. crypto.HashAlgorithm.Sha3_256 : HashAlgorithm
214. crypto.HashAlgorithm.Sha3_512 : HashAlgorithm
215. crypto.hash : HashAlgorithm -> a -> Bytes
216. crypto.hashBytes : HashAlgorithm -> Bytes -> Bytes
217. crypto.hmac : HashAlgorithm -> Bytes -> a -> Bytes
218. crypto.hmacBytes : HashAlgorithm
-> Bytes
-> Bytes
-> Bytes
221. unique type io2.BufferMode
222. io2.BufferMode.BlockBuffering : BufferMode
223. io2.BufferMode.LineBuffering : BufferMode
224. io2.BufferMode.NoBuffering : BufferMode
225. io2.BufferMode.SizedBlockBuffering : Nat -> BufferMode
226. unique type io2.Failure
227. io2.Failure.Failure : Type -> Text -> Any -> Failure
228. unique type io2.FileMode
229. io2.FileMode.Append : FileMode
230. io2.FileMode.Read : FileMode
231. io2.FileMode.ReadWrite : FileMode
232. io2.FileMode.Write : FileMode
233. builtin type io2.Handle
234. builtin type io2.IO
235. io2.IO.clientSocket.impl : Text
219. unique type io2.BufferMode
220. io2.BufferMode.BlockBuffering : BufferMode
221. io2.BufferMode.LineBuffering : BufferMode
222. io2.BufferMode.NoBuffering : BufferMode
223. io2.BufferMode.SizedBlockBuffering : Nat -> BufferMode
224. unique type io2.Failure
225. io2.Failure.Failure : Type -> Text -> Any -> Failure
226. unique type io2.FileMode
227. io2.FileMode.Append : FileMode
228. io2.FileMode.Read : FileMode
229. io2.FileMode.ReadWrite : FileMode
230. io2.FileMode.Write : FileMode
231. builtin type io2.Handle
232. builtin type io2.IO
233. io2.IO.clientSocket.impl : Text
-> Text
->{IO} Either Failure Socket
236. io2.IO.closeFile.impl : Handle ->{IO} Either Failure ()
237. io2.IO.closeSocket.impl : Socket ->{IO} Either Failure ()
238. io2.IO.createDirectory.impl : Text
234. io2.IO.closeFile.impl : Handle ->{IO} Either Failure ()
235. io2.IO.closeSocket.impl : Socket ->{IO} Either Failure ()
236. io2.IO.createDirectory.impl : Text
->{IO} Either Failure ()
239. io2.IO.createTempDirectory.impl : Text
237. io2.IO.createTempDirectory.impl : Text
->{IO} Either
Failure Text
240. io2.IO.delay.impl : Nat ->{IO} Either Failure ()
241. io2.IO.fileExists.impl : Text
238. io2.IO.delay.impl : Nat ->{IO} Either Failure ()
239. io2.IO.fileExists.impl : Text
->{IO} Either Failure Boolean
242. io2.IO.forkComp : '{IO} a ->{IO} ThreadId
243. io2.IO.getBuffering.impl : Handle
240. io2.IO.forkComp : '{IO} a ->{IO} ThreadId
241. io2.IO.getBuffering.impl : Handle
->{IO} Either
Failure BufferMode
244. io2.IO.getBytes.impl : Handle
242. io2.IO.getBytes.impl : Handle
-> Nat
->{IO} Either Failure Bytes
245. io2.IO.getCurrentDirectory.impl : '{IO} Either
243. io2.IO.getCurrentDirectory.impl : '{IO} Either
Failure Text
246. io2.IO.getFileSize.impl : Text ->{IO} Either Failure Nat
247. io2.IO.getFileTimestamp.impl : Text
244. io2.IO.getFileSize.impl : Text ->{IO} Either Failure Nat
245. io2.IO.getFileTimestamp.impl : Text
->{IO} Either Failure Nat
248. io2.IO.getTempDirectory.impl : '{IO} Either Failure Text
249. io2.IO.handlePosition.impl : Handle
246. io2.IO.getTempDirectory.impl : '{IO} Either Failure Text
247. io2.IO.handlePosition.impl : Handle
->{IO} Either Failure Nat
250. io2.IO.isDirectory.impl : Text
248. io2.IO.isDirectory.impl : Text
->{IO} Either Failure Boolean
251. io2.IO.isFileEOF.impl : Handle
249. io2.IO.isFileEOF.impl : Handle
->{IO} Either Failure Boolean
252. io2.IO.isFileOpen.impl : Handle
250. io2.IO.isFileOpen.impl : Handle
->{IO} Either Failure Boolean
253. io2.IO.isSeekable.impl : Handle
251. io2.IO.isSeekable.impl : Handle
->{IO} Either Failure Boolean
254. io2.IO.kill.impl : ThreadId ->{IO} Either Failure ()
255. io2.IO.listen.impl : Socket ->{IO} Either Failure ()
256. io2.IO.openFile.impl : Text
252. io2.IO.kill.impl : ThreadId ->{IO} Either Failure ()
253. io2.IO.listen.impl : Socket ->{IO} Either Failure ()
254. io2.IO.openFile.impl : Text
-> FileMode
->{IO} Either Failure Handle
257. io2.IO.putBytes.impl : Handle
255. io2.IO.putBytes.impl : Handle
-> Bytes
->{IO} Either Failure ()
258. io2.IO.removeDirectory.impl : Text
256. io2.IO.removeDirectory.impl : Text
->{IO} Either Failure ()
259. io2.IO.removeFile.impl : Text ->{IO} Either Failure ()
260. io2.IO.renameDirectory.impl : Text
257. io2.IO.removeFile.impl : Text ->{IO} Either Failure ()
258. io2.IO.renameDirectory.impl : Text
-> Text
->{IO} Either Failure ()
261. io2.IO.renameFile.impl : Text
259. io2.IO.renameFile.impl : Text
-> Text
->{IO} Either Failure ()
262. io2.IO.seekHandle.impl : Handle
260. io2.IO.seekHandle.impl : Handle
-> SeekMode
-> Int
->{IO} Either Failure ()
263. io2.IO.serverSocket.impl : Optional Text
261. io2.IO.serverSocket.impl : Optional Text
-> Text
->{IO} Either Failure Socket
264. io2.IO.setBuffering.impl : Handle
262. io2.IO.setBuffering.impl : Handle
-> BufferMode
->{IO} Either Failure ()
265. io2.IO.setCurrentDirectory.impl : Text
263. io2.IO.setCurrentDirectory.impl : Text
->{IO} Either
Failure ()
266. io2.IO.socketAccept.impl : Socket
264. io2.IO.socketAccept.impl : Socket
->{IO} Either Failure Socket
267. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat
268. io2.IO.socketReceive.impl : Socket
265. io2.IO.socketPort.impl : Socket ->{IO} Either Failure Nat
266. io2.IO.socketReceive.impl : Socket
-> Nat
->{IO} Either Failure Bytes
269. io2.IO.socketSend.impl : Socket
267. io2.IO.socketSend.impl : Socket
-> Bytes
->{IO} Either Failure ()
270. io2.IO.stdHandle : StdHandle -> Handle
271. io2.IO.systemTime.impl : '{IO} Either Failure Nat
272. unique type io2.IOError
273. io2.IOError.AlreadyExists : IOError
274. io2.IOError.EOF : IOError
275. io2.IOError.IllegalOperation : IOError
276. io2.IOError.NoSuchThing : IOError
277. io2.IOError.PermissionDenied : IOError
278. io2.IOError.ResourceBusy : IOError
279. io2.IOError.ResourceExhausted : IOError
280. io2.IOError.UserError : IOError
281. unique type io2.IOFailure
282. builtin type io2.MVar
283. io2.MVar.isEmpty : MVar a ->{IO} Boolean
284. io2.MVar.new : a ->{IO} MVar a
285. io2.MVar.newEmpty : '{IO} MVar a
286. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure ()
287. io2.MVar.read.impl : MVar a ->{IO} Either Failure a
288. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a
289. io2.MVar.take.impl : MVar a ->{IO} Either Failure a
290. io2.MVar.tryPut.impl : MVar a
268. io2.IO.stdHandle : StdHandle -> Handle
269. io2.IO.systemTime.impl : '{IO} Either Failure Nat
270. unique type io2.IOError
271. io2.IOError.AlreadyExists : IOError
272. io2.IOError.EOF : IOError
273. io2.IOError.IllegalOperation : IOError
274. io2.IOError.NoSuchThing : IOError
275. io2.IOError.PermissionDenied : IOError
276. io2.IOError.ResourceBusy : IOError
277. io2.IOError.ResourceExhausted : IOError
278. io2.IOError.UserError : IOError
279. unique type io2.IOFailure
280. builtin type io2.MVar
281. io2.MVar.isEmpty : MVar a ->{IO} Boolean
282. io2.MVar.new : a ->{IO} MVar a
283. io2.MVar.newEmpty : '{IO} MVar a
284. io2.MVar.put.impl : MVar a -> a ->{IO} Either Failure ()
285. io2.MVar.read.impl : MVar a ->{IO} Either Failure a
286. io2.MVar.swap.impl : MVar a -> a ->{IO} Either Failure a
287. io2.MVar.take.impl : MVar a ->{IO} Either Failure a
288. io2.MVar.tryPut.impl : MVar a
-> a
->{IO} Either Failure Boolean
291. io2.MVar.tryRead.impl : MVar a
289. io2.MVar.tryRead.impl : MVar a
->{IO} Either
Failure (Optional a)
292. io2.MVar.tryTake : MVar a ->{IO} Optional a
293. builtin type io2.STM
294. io2.STM.atomically : '{STM} a ->{IO} a
295. io2.STM.retry : '{STM} a
296. unique type io2.SeekMode
297. io2.SeekMode.AbsoluteSeek : SeekMode
298. io2.SeekMode.RelativeSeek : SeekMode
299. io2.SeekMode.SeekFromEnd : SeekMode
300. builtin type io2.Socket
301. unique type io2.StdHandle
302. io2.StdHandle.StdErr : StdHandle
303. io2.StdHandle.StdIn : StdHandle
304. io2.StdHandle.StdOut : StdHandle
305. io2.TLS.ClientConfig.ciphers.set : [##Tls.Cipher]
290. io2.MVar.tryTake : MVar a ->{IO} Optional a
291. builtin type io2.STM
292. io2.STM.atomically : '{STM} a ->{IO} a
293. io2.STM.retry : '{STM} a
294. unique type io2.SeekMode
295. io2.SeekMode.AbsoluteSeek : SeekMode
296. io2.SeekMode.RelativeSeek : SeekMode
297. io2.SeekMode.SeekFromEnd : SeekMode
298. builtin type io2.Socket
299. unique type io2.StdHandle
300. io2.StdHandle.StdErr : StdHandle
301. io2.StdHandle.StdIn : StdHandle
302. io2.StdHandle.StdOut : StdHandle
303. io2.TLS.ClientConfig.ciphers.set : [##Tls.Cipher]
-> ClientConfig
-> ClientConfig
306. builtin type io2.TVar
307. io2.TVar.new : a ->{STM} TVar a
308. io2.TVar.newIO : a ->{IO} TVar a
309. io2.TVar.read : TVar a ->{STM} a
310. io2.TVar.readIO : TVar a ->{IO} a
311. io2.TVar.swap : TVar a -> a ->{STM} a
312. io2.TVar.write : TVar a -> a ->{STM} ()
313. builtin type io2.ThreadId
314. builtin type io2.Tls
315. builtin type io2.Tls.ClientConfig
316. io2.Tls.ClientConfig.certificates.set : [SignedCert]
304. builtin type io2.TVar
305. io2.TVar.new : a ->{STM} TVar a
306. io2.TVar.newIO : a ->{IO} TVar a
307. io2.TVar.read : TVar a ->{STM} a
308. io2.TVar.readIO : TVar a ->{IO} a
309. io2.TVar.swap : TVar a -> a ->{STM} a
310. io2.TVar.write : TVar a -> a ->{STM} ()
311. builtin type io2.ThreadId
312. builtin type io2.Tls
313. builtin type io2.Tls.ClientConfig
314. io2.Tls.ClientConfig.certificates.set : [SignedCert]
-> ClientConfig
-> ClientConfig
317. io2.Tls.ClientConfig.default : Text
315. io2.Tls.ClientConfig.default : Text
-> Bytes
-> ClientConfig
318. io2.Tls.ClientConfig.versions.set : [##Tls.Version]
316. io2.Tls.ClientConfig.versions.set : [##Tls.Version]
-> ClientConfig
-> ClientConfig
319. builtin type io2.Tls.PrivateKey
320. builtin type io2.Tls.ServerConfig
321. io2.Tls.ServerConfig.certificates.set : [SignedCert]
317. builtin type io2.Tls.PrivateKey
318. builtin type io2.Tls.ServerConfig
319. io2.Tls.ServerConfig.certificates.set : [SignedCert]
-> ServerConfig
-> ServerConfig
322. io2.Tls.ServerConfig.ciphers.set : [##Tls.Cipher]
320. io2.Tls.ServerConfig.ciphers.set : [##Tls.Cipher]
-> ServerConfig
-> ServerConfig
323. io2.Tls.ServerConfig.default : [SignedCert]
321. io2.Tls.ServerConfig.default : [SignedCert]
-> PrivateKey
-> ServerConfig
324. io2.Tls.ServerConfig.versions.set : [##Tls.Version]
322. io2.Tls.ServerConfig.versions.set : [##Tls.Version]
-> ServerConfig
-> ServerConfig
325. builtin type io2.Tls.SignedCert
326. io2.Tls.decodeCert.impl : Bytes
323. builtin type io2.Tls.SignedCert
324. io2.Tls.decodeCert.impl : Bytes
-> Either Failure SignedCert
327. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey]
328. io2.Tls.encodeCert : SignedCert -> Bytes
329. io2.Tls.encodePrivateKey : PrivateKey -> Bytes
330. io2.Tls.handshake.impl : Tls ->{IO} Either Failure ()
331. io2.Tls.newClient.impl : ClientConfig
325. io2.Tls.decodePrivateKey : Bytes -> [PrivateKey]
326. io2.Tls.encodeCert : SignedCert -> Bytes
327. io2.Tls.encodePrivateKey : PrivateKey -> Bytes
328. io2.Tls.handshake.impl : Tls ->{IO} Either Failure ()
329. io2.Tls.newClient.impl : ClientConfig
-> Socket
->{IO} Either Failure Tls
332. io2.Tls.newServer.impl : ServerConfig
330. io2.Tls.newServer.impl : ServerConfig
-> Socket
->{IO} Either Failure Tls
333. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes
334. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure ()
335. io2.Tls.terminate.impl : Tls ->{IO} Either Failure ()
336. unique type io2.TlsFailure
337. metadata.isPropagated : IsPropagated
338. metadata.isTest : IsTest
339. todo : a -> b
331. io2.Tls.receive.impl : Tls ->{IO} Either Failure Bytes
332. io2.Tls.send.impl : Tls -> Bytes ->{IO} Either Failure ()
333. io2.Tls.terminate.impl : Tls ->{IO} Either Failure ()
334. unique type io2.TlsFailure
335. metadata.isPropagated : IsPropagated
336. metadata.isTest : IsTest
337. todo : a -> b
.builtin> alias.many 94-104 .mylib
@ -433,17 +431,17 @@ Let's try it!
Added definitions:
1. Int.isOdd : Int -> Boolean
2. Int.leadingZeros : Int -> Nat
3. Int.lt : Int -> Int -> Boolean
4. Int.lteq : Int -> Int -> Boolean
5. Int.mod : Int -> Int -> Int
6. Int.negate : Int -> Int
7. Int.or : Int -> Int -> Int
8. Int.popCount : Int -> Nat
9. Int.pow : Int -> Nat -> Int
10. Int.shiftLeft : Int -> Nat -> Int
11. Int.shiftRight : Int -> Nat -> Int
1. Int.isEven : Int -> Boolean
2. Int.isOdd : Int -> Boolean
3. Int.leadingZeros : Int -> Nat
4. Int.lt : Int -> Int -> Boolean
5. Int.lteq : Int -> Int -> Boolean
6. Int.mod : Int -> Int -> Int
7. Int.negate : Int -> Int
8. Int.or : Int -> Int -> Int
9. Int.popCount : Int -> Nat
10. Int.pow : Int -> Nat -> Int
11. Int.shiftLeft : Int -> Nat -> Int
Tip: You can use `undo` or `reflog` to undo this change.
@ -505,17 +503,17 @@ I want to incorporate a few more from another namespace:
.mylib> find
1. Int.isOdd : Int -> Boolean
2. Int.leadingZeros : Int -> Nat
3. Int.lt : Int -> Int -> Boolean
4. Int.lteq : Int -> Int -> Boolean
5. Int.mod : Int -> Int -> Int
6. Int.negate : Int -> Int
7. Int.or : Int -> Int -> Int
8. Int.popCount : Int -> Nat
9. Int.pow : Int -> Nat -> Int
10. Int.shiftLeft : Int -> Nat -> Int
11. Int.shiftRight : Int -> Nat -> Int
1. Int.isEven : Int -> Boolean
2. Int.isOdd : Int -> Boolean
3. Int.leadingZeros : Int -> Nat
4. Int.lt : Int -> Int -> Boolean
5. Int.lteq : Int -> Int -> Boolean
6. Int.mod : Int -> Int -> Int
7. Int.negate : Int -> Int
8. Int.or : Int -> Int -> Int
9. Int.popCount : Int -> Nat
10. Int.pow : Int -> Nat -> Int
11. Int.shiftLeft : Int -> Nat -> Int
12. List.adjacentPairs : [a] -> [(a, a)]
13. List.all : (a ->{g} Boolean) ->{g} [a] ->{g} Boolean
14. List.any : (a ->{g} Boolean) ->{g} [a] ->{g} Boolean

View File

@ -16,7 +16,7 @@ The `builtins.merge` command adds the known builtins to a `builtin` subnamespace
5. Bytes (builtin type)
6. Bytes/ (17 definitions)
7. Char (builtin type)
8. Char/ (2 definitions)
8. Char/ (3 definitions)
9. Code (builtin type)
10. Code/ (6 definitions)
11. Debug/ (1 definition)
@ -45,7 +45,7 @@ The `builtins.merge` command adds the known builtins to a `builtin` subnamespace
34. SeqView/ (2 definitions)
35. Test/ (3 definitions)
36. Text (builtin type)
37. Text/ (21 definitions)
37. Text/ (18 definitions)
38. Tuple (type)
39. Tuple/ (1 definition)
40. Unit (type)

View File

@ -23,7 +23,7 @@ Technically, the definitions all exist, but they have no names. `builtins.merge`
.foo> ls
1. builtin/ (339 definitions)
1. builtin/ (337 definitions)
```
And for a limited time, you can get even more builtin goodies:

View File

@ -112,13 +112,13 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
Note: The most recent namespace hash is immediately below this
message.
#7nrjt5udro
#dr7j21cpqp
- Deletes:
feature1.y
#js1k2kt6sg
#0ct10skh45
+ Adds / updates:
@ -129,26 +129,26 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
Original name New name(s)
feature1.y master.y
#vo41gk2trr
#8sknads6vj
+ Adds / updates:
feature1.y
#llp0l646ob
#hb8qfqt9ai
> Moves:
Original name New name
x master.x
#tjb9j25vp8
#73mdo6cqdj
+ Adds / updates:
x
#cagreovqu2
#q1npn63eti
+ Adds / updates:
@ -162,20 +162,20 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
builtin.Bytes.toBase16 builtin.Bytes.toBase32
builtin.Bytes.toBase64 builtin.Bytes.toBase64UrlUnpadded
builtin.Bytes.toList builtin.Char builtin.Char.fromNat
builtin.Char.toNat builtin.Code builtin.Code.cache_
builtin.Code.dependencies builtin.Code.deserialize
builtin.Code.isMissing builtin.Code.lookup
builtin.Code.serialize builtin.Debug.watch builtin.Doc
builtin.Doc.Blob builtin.Doc.Evaluate builtin.Doc.Join
builtin.Doc.Link builtin.Doc.Signature builtin.Doc.Source
builtin.Either builtin.Either.Left builtin.Either.Right
builtin.Float builtin.Float.* builtin.Float.+
builtin.Float.- builtin.Float./ builtin.Float.abs
builtin.Float.acos builtin.Float.acosh builtin.Float.asin
builtin.Float.asinh builtin.Float.atan builtin.Float.atan2
builtin.Float.atanh builtin.Float.ceiling
builtin.Float.cos builtin.Float.cosh builtin.Float.eq
builtin.Float.exp builtin.Float.floor
builtin.Char.toNat builtin.Char.toText builtin.Code
builtin.Code.cache_ builtin.Code.dependencies
builtin.Code.deserialize builtin.Code.isMissing
builtin.Code.lookup builtin.Code.serialize
builtin.Debug.watch builtin.Doc builtin.Doc.Blob
builtin.Doc.Evaluate builtin.Doc.Join builtin.Doc.Link
builtin.Doc.Signature builtin.Doc.Source builtin.Either
builtin.Either.Left builtin.Either.Right builtin.Float
builtin.Float.* builtin.Float.+ builtin.Float.-
builtin.Float./ builtin.Float.abs builtin.Float.acos
builtin.Float.acosh builtin.Float.asin builtin.Float.asinh
builtin.Float.atan builtin.Float.atan2 builtin.Float.atanh
builtin.Float.ceiling builtin.Float.cos builtin.Float.cosh
builtin.Float.eq builtin.Float.exp builtin.Float.floor
builtin.Float.fromText builtin.Float.gt builtin.Float.gteq
builtin.Float.log builtin.Float.logBase builtin.Float.lt
builtin.Float.lteq builtin.Float.max builtin.Float.min
@ -217,9 +217,7 @@ We can also delete the fork if we're done with it. (Don't worry, it's still in t
builtin.SeqView.VEmpty builtin.Test.Result
builtin.Test.Result.Fail builtin.Test.Result.Ok
builtin.Text builtin.Text.!= builtin.Text.++
builtin.Text.alignCenterWith builtin.Text.alignLeftWith
builtin.Text.alignRightWith builtin.Text.drop
builtin.Text.empty builtin.Text.eq
builtin.Text.drop builtin.Text.empty builtin.Text.eq
builtin.Text.fromCharList builtin.Text.fromUtf8.impl
builtin.Text.gt builtin.Text.gteq builtin.Text.lt
builtin.Text.lteq builtin.Text.repeat builtin.Text.size

View File

@ -59,16 +59,16 @@ y = 2
most recent, along with the command that got us there. Try:
`fork 2 .old`
`fork #muuob1ft4i .old` to make an old namespace
`fork #pknj0m8137 .old` to make an old namespace
accessible again,
`reset-root #muuob1ft4i` to reset the root namespace and
`reset-root #pknj0m8137` to reset the root namespace and
its history to that of the
specified namespace.
1. #rnp7c59gbm : add
2. #muuob1ft4i : add
3. #cagreovqu2 : builtins.merge
1. #j376pgmitc : add
2. #pknj0m8137 : add
3. #q1npn63eti : builtins.merge
4. #7asfbtqmoj : (initial reflogged namespace)
```

View File

@ -13,7 +13,7 @@ Let's look at some examples. We'll start with a namespace with just the builtins
#6mnnbcegt3 (start of history)
#klkpbos013 (start of history)
.> fork builtin builtin2
@ -42,21 +42,21 @@ Now suppose we `fork` a copy of builtin, then rename `Nat.+` to `frobnicate`, th
Note: The most recent namespace hash is immediately below this
message.
#j044t32b40
#2389gjnigh
> Moves:
Original name New name
Nat.frobnicate Nat.+
#99ajdi7m33
#l7dr0sq1vj
> Moves:
Original name New name
Nat.+ Nat.frobnicate
#6mnnbcegt3 (start of history)
#klkpbos013 (start of history)
```
If we merge that back into `builtin`, we get that same chain of history:
@ -71,21 +71,21 @@ If we merge that back into `builtin`, we get that same chain of history:
Note: The most recent namespace hash is immediately below this
message.
#j044t32b40
#2389gjnigh
> Moves:
Original name New name
Nat.frobnicate Nat.+
#99ajdi7m33
#l7dr0sq1vj
> Moves:
Original name New name
Nat.+ Nat.frobnicate
#6mnnbcegt3 (start of history)
#klkpbos013 (start of history)
```
Let's try again, but using a `merge.squash` (or just `squash`) instead. The history will be unchanged:
@ -106,7 +106,7 @@ Let's try again, but using a `merge.squash` (or just `squash`) instead. The hist
#6mnnbcegt3 (start of history)
#klkpbos013 (start of history)
```
The churn that happened in `mybuiltin` namespace ended up back in the same spot, so the squash merge of that namespace with our original namespace had no effect.