Skip to content

Commit 1739994

Browse files
committed
update outdated docs examples
1 parent 4ca7ff1 commit 1739994

File tree

6 files changed

+21
-24
lines changed

6 files changed

+21
-24
lines changed

platform/Cmd.roc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ status! = |@Cmd(cmd)|
131131
##
132132
## ```
133133
## # Call echo to print "hello world"
134-
## Cmd.exec!("echo", ["hello world"])
134+
## Cmd.exec!("echo", ["hello world"]) ? |err| CmdEchoFailed(err)
135135
## ```
136136
exec! : Str, List Str => Result {} [CmdStatusErr InternalIOErr.IOErr]
137137
exec! = |program, arguments|

platform/File.roc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ IOErr : InternalIOErr.IOErr
5353
##
5454
## First encode a `val` using a given `fmt` which implements the ability [Encode.EncoderFormatting](https://www.roc-lang.org/builtins/Encode#EncoderFormatting).
5555
##
56-
## For example, suppose you have a `Json.to_compact_utf8` which implements
56+
## For example, suppose you have a `Json.utf8` which implements
5757
## [Encode.EncoderFormatting](https://www.roc-lang.org/builtins/Encode#EncoderFormatting).
5858
## You can use this to write [JSON](https://en.wikipedia.org/wiki/JSON)
5959
## data to a file like this:
@@ -62,9 +62,9 @@ IOErr : InternalIOErr.IOErr
6262
## # Writes `{"some":"json stuff"}` to the file `output.json`:
6363
## File.write!(
6464
## { some: "json stuff" },
65-
## Path.from_str("output.json"),
66-
## Json.to_compact_utf8,
67-
## )
65+
## "output.json",
66+
## Json.utf8,
67+
## )?
6868
## ```
6969
##
7070
## This opens the file first and closes it after writing to it.
@@ -81,7 +81,7 @@ write! = |val, path_str, fmt|
8181
##
8282
## ```
8383
## # Writes the bytes 1, 2, 3 to the file `myfile.dat`.
84-
## File.write_bytes!([1, 2, 3], Path.from_str("myfile.dat"))?
84+
## File.write_bytes!([1, 2, 3], "myfile.dat")?
8585
## ```
8686
##
8787
## This opens the file first and closes it after writing to it.
@@ -119,7 +119,7 @@ write_utf8! = |str, path_str|
119119
##
120120
## ```
121121
## # Deletes the file named `myfile.dat`
122-
## File.delete!(Path.from_str("myfile.dat"), [1, 2, 3])?
122+
## File.delete!("myfile.dat")?
123123
## ```
124124
##
125125
## > This does not securely erase the file's contents from disk; instead, the operating
@@ -166,9 +166,6 @@ read_utf8! : Str => Result Str [FileReadErr Path IOErr, FileReadUtf8Err Path _]
166166
read_utf8! = |path_str|
167167
Path.read_utf8!(Path.from_str(path_str))
168168

169-
# read : Str, fmt => Result contents [FileReadErr Path ReadErr, FileReadDecodingFailed] where contents implements Decoding, fmt implements DecoderFormatting
170-
# read = |path, fmt|
171-
# Path.read! (Path.from_str path) fmt
172169

173170
## Creates a new [hard link](https://en.wikipedia.org/wiki/Hard_link) on the filesystem.
174171
##

platform/Http.roc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Response : InternalHttp.Response
6060
## ```
6161
## # GET "roc-lang.org"
6262
## { Http.default_request &
63-
## url: "https://www.roc-lang.org",
63+
## uri: "https://www.roc-lang.org",
6464
## }
6565
## ```
6666
##
@@ -88,9 +88,9 @@ header = |(name, value)| { name, value }
8888
## # Prints out the HTML of the Roc-lang website.
8989
## response : Response
9090
## response =
91-
## Http.send!({ Http.default_request & url: "https://www.roc-lang.org" })?
91+
## Http.send!({ Http.default_request & uri: "https://www.roc-lang.org" })?
9292
##
93-
## Stdout.line(Str.from_utf8(response.body))?
93+
## Stdout.line!(Str.from_utf8(response.body))?
9494
## ```
9595
send! : Request => Result Response [HttpErr [Timeout, NetworkError, BadBody, Other (List U8)]]
9696
send! = |request|

platform/Path.roc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ IOErr : InternalIOErr.IOErr
3939
##
4040
## First encode a `val` using a given `fmt` which implements the ability [Encode.EncoderFormatting](https://www.roc-lang.org/builtins/Encode#EncoderFormatting).
4141
##
42-
## For example, suppose you have a `Json.to_compact_utf8` which implements
42+
## For example, suppose you have a `Json.utf8` which implements
4343
## [Encode.EncoderFormatting](https://www.roc-lang.org/builtins/Encode#EncoderFormatting).
4444
## You can use this to write [JSON](https://en.wikipedia.org/wiki/JSON)
4545
## data to a file like this:
@@ -49,7 +49,7 @@ IOErr : InternalIOErr.IOErr
4949
## Path.write!(
5050
## { some: "json stuff" },
5151
## Path.from_str("output.json"),
52-
## Json.to_compact_utf8,
52+
## Json.utf8,
5353
## )?
5454
## ```
5555
##
@@ -264,7 +264,7 @@ with_extension = |path, extension|
264264
##
265265
## ```
266266
## # Deletes the file named `myfile.dat`
267-
## Path.delete(Path.from_str("myfile.dat"), [1, 2, 3])?
267+
## Path.delete!(Path.from_str("myfile.dat"))?
268268
## ```
269269
##
270270
## > This does not securely erase the file's contents from disk; instead, the operating
@@ -273,7 +273,7 @@ with_extension = |path, extension|
273273
## the last file handle to it is closed, and on UNIX, it will not remove it until the last
274274
## [hard link](https://en.wikipedia.org/wiki/Hard_link) to it has been deleted.
275275
##
276-
## > [`File.delete`](File#delete!) does the same thing, except it takes a [Str] instead of a [Path].
276+
## > [`File.delete!`](File#delete!) does the same thing, except it takes a [Str] instead of a [Path].
277277
delete! : Path => Result {} [FileWriteErr Path IOErr]
278278
delete! = |path|
279279
Host.file_delete!(InternalPath.to_bytes(path))
@@ -283,15 +283,15 @@ delete! = |path|
283283
##
284284
## ```
285285
## # Reads UTF-8 encoded text into a Str from the file "myfile.txt"
286-
## contents_str = Path.read_utf8(Path.from_str("myfile.txt"))?
286+
## contents_str = Path.read_utf8!(Path.from_str("myfile.txt"))?
287287
## ```
288288
##
289289
## This opens the file first and closes it after reading its contents.
290290
## The task will fail with `FileReadUtf8Err` if the given file contains invalid UTF-8.
291291
##
292292
## > To read unformatted bytes from a file, you can use [Path.read_bytes!] instead.
293293
## >
294-
## > [`File.read_utf8`](File#read_utf8!) does the same thing, except it takes a [Str] instead of a [Path].
294+
## > [`File.read_utf8!`](File#read_utf8!) does the same thing, except it takes a [Str] instead of a [Path].
295295
read_utf8! : Path => Result Str [FileReadErr Path IOErr, FileReadUtf8Err Path _]
296296
read_utf8! = |path|
297297
bytes =

platform/Sqlite.roc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Stmt := Box {}
159159
## id: Sqlite.i64("id"),
160160
## task: Sqlite.str("task"),
161161
## },
162-
## })
162+
## })?
163163
## ```
164164
prepare! :
165165
{

platform/Tcp.roc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ connect! = |host, port|
9393
##
9494
## ```
9595
## # Read up to 64 bytes from the stream
96-
## received_bytes = File.read_up_to!(stream, 64)?
96+
## received_bytes = Tcp.read_up_to!(stream, 64)?
9797
## ```
9898
##
9999
## > To read an exact number of bytes or fail, you can use [Tcp.read_exactly!] instead.
@@ -105,7 +105,7 @@ read_up_to! = |@Stream(stream), bytes_to_read|
105105
## Read an exact number of bytes or fail.
106106
##
107107
## ```
108-
## bytes = File.read_exactly!(stream, 64)?
108+
## bytes = Tcp.read_exactly!(stream, 64)?
109109
## ```
110110
##
111111
## `TcpUnexpectedEOF` is returned if the stream ends before the specfied number of bytes is reached.
@@ -125,7 +125,7 @@ read_exactly! = |@Stream(stream), bytes_to_read|
125125
##
126126
## ```
127127
## # Read until null terminator
128-
## bytes = File.read_until!(stream, 0)?
128+
## bytes = Tcp.read_until!(stream, 0)?
129129
## ```
130130
##
131131
## If found, the delimiter is included as the last byte.
@@ -141,7 +141,7 @@ read_until! = |@Stream(stream), byte|
141141
##
142142
## ```
143143
## # Read a line and then print it to `stdout`
144-
## line_str = File.read_line!(stream)?
144+
## line_str = Tcp.read_line!(stream)?
145145
## Stdout.line(line_str)?
146146
## ```
147147
##

0 commit comments

Comments
 (0)