12 | ||| Create a string by using n copies of a character
17 | ||| Indent a given string by `n` spaces.
22 | ||| Pad a string on the left
27 | ||| Pad a string on the right
32 | -- This uses fastConcat internally so it won't compute at compile time.
33 | export
40 | ||| Splits a string into a list of whitespace separated strings.
41 | |||
42 | ||| ```idris example
43 | ||| words " A B C D E "
44 | ||| ```
48 | where
49 | -- append a word to the list of words, only if it's non-empty
54 | ||| Splits a character list into a list of whitespace separated character lists.
55 | |||
56 | ||| ```idris example
57 | ||| words' (unpack " A B C D E ") [<] [<]
58 | ||| ```
69 | ||| Joins the strings using the provided separator
70 | ||| ```idris example
71 | ||| joinBy ", " ["A", "BC", "D"] === "A, BC, D"
72 | ||| ```
77 | ||| Joins the strings by spaces into a single string.
78 | |||
79 | ||| ```idris example
80 | ||| unwords ["A", "BC", "D", "E"] === "A BC D E"
81 | ||| ```
86 | ||| Splits a character list into a list of newline separated character lists.
87 | |||
88 | ||| The empty string becomes an empty list. The last newline, if not followed by
89 | ||| any additional characters, is eaten (there will never be an empty string last element
90 | ||| in the result).
91 | |||
92 | ||| ```idris example
93 | ||| lines' (unpack "\rA BC\nD\r\nE\n")
94 | ||| ```
107 | ||| Splits a string into a list of newline separated strings.
108 | |||
109 | ||| The empty string becomes an empty list. The last newline, if not followed by
110 | ||| any additional characters, is eaten (there will never be an empty string last element
111 | ||| in the result).
112 | |||
113 | ||| ```idris example
114 | ||| lines "\rA BC\nD\r\nE\n"
115 | ||| ```
120 | ||| Joins the strings into a single string by appending a newline to each string.
121 | |||
122 | ||| ```idris example
123 | ||| unlines ["line", "line2", "ln3", "D"]
124 | ||| ```
131 | ||| A view checking whether a string is empty
132 | ||| and, if not, returning its head and tail
138 | ||| To each string we can associate its StrM view
143 | -- Using primitives, so `assert_total` and `believe_me` needed
147 | ||| A view of a string as a lazy linked list of characters
153 | ||| To each string we can associate the lazy linked list of characters
154 | ||| it corresponds to once unpacked.
161 | ||| Trim whitespace on the left of the string
168 | ||| Trim whitespace on the right of the string
173 | ||| Trim whitespace on both sides of the string
178 | ||| Splits the string into a part before the predicate
179 | ||| returns False and the rest of the string.
180 | |||
181 | ||| ```idris example
182 | ||| span (/= 'C') "ABCD"
183 | ||| ```
184 | ||| ```idris example
185 | ||| span (/= 'C') "EFGH"
186 | ||| ```
193 | ||| Splits the string into a part before the predicate
194 | ||| returns True and the rest of the string.
195 | |||
196 | ||| ```idris example
197 | ||| break (== 'C') "ABCD"
198 | ||| ```
199 | ||| ```idris example
200 | ||| break (== 'C') "EFGH"
201 | ||| ```
207 | ||| Splits the string into parts with the predicate
208 | ||| indicating separator characters.
209 | |||
210 | ||| ```idris example
211 | ||| split (== '.') ".AB.C..D"
212 | ||| ```
265 | ||| Convert a positive number string to a Num.
266 | |||
267 | ||| ```idris example
268 | ||| parsePositive "123"
269 | ||| ```
270 | ||| ```idris example
271 | ||| parsePositive {a=Int} " +123"
272 | ||| ```
276 | where
284 | then map fromInteger (parseNumWithoutSign (unpack xs) (cast (ord x - ord '0')))
285 | else Nothing
287 | ||| Convert a number string to a Num.
288 | |||
289 | ||| ```idris example
290 | ||| parseInteger " 123"
291 | ||| ```
292 | ||| ```idris example
293 | ||| parseInteger {a=Int} " -123"
294 | ||| ```
295 | public export
298 | where
312 | ||| Convert a number string to a Double.
313 | |||
314 | ||| ```idris example
315 | ||| parseDouble "+123.123e-2"
316 | ||| ```
317 | ||| ```idris example
318 | ||| parseDouble " -123.123E+2"
319 | ||| ```
320 | ||| ```idris example
321 | ||| parseDouble " +123.123"
322 | ||| ```
324 | covering
327 | where
330 | where
352 | do
357 | do
365 | do
372 | do
380 | -- sign, whole, fractional, exponent