diff options
author | Alexandru-Sergiu Marton <brown121407@member.fsf.org> | 2020-04-18 14:37:17 +0300 |
---|---|---|
committer | Alexandru-Sergiu Marton <brown121407@member.fsf.org> | 2020-04-18 14:37:17 +0300 |
commit | 76e34c072fb6783dc7bb180f423687a1bf9ea1f9 (patch) | |
tree | 148c18c0cbdae8cdf664ffd9a38870b3fe97e194 | |
parent | f5fcbe5f68ee87104f47f1a5d0cdab9b2511b1ef (diff) |
Add a bit of documentation.
-rw-r--r-- | README.md | 44 |
1 files changed, 41 insertions, 3 deletions
@@ -35,7 +35,7 @@ f.scm provides two Guile modules: `(f p)` and `(f)`. - `(f)`: this contains functions that always get passed a path and open a new port for that path. -- `(f p)`: this mirrors some functions from `(f)`, receiving already +- `(f ports)`: this mirrors some functions from `(f)`, receiving already opened ports instead of paths. It is recommended to import those modules with a prefix so they don't @@ -43,12 +43,50 @@ overwrite each other and some top-level functions. ```scheme (use-modules ((f) #:prefix f:) - ((f p) #:prefix p:)) + ((f ports) #:prefix p:)) ``` If you want to read _only_ the first line of a file, you can use the `read-line` from `(f)`. If you want to read the next line from an -already opened port, use the `read-line` from `(f p)`. +already opened port, use the `read-line` from `(f ports)`. + +**NOTE**: All the examples below assume you imported `f` with the `f:` +prefix and `f p` with the `p:` prefix. + +## f + +### `read-bytes path` +Read binary data from `path`. + +Return the binary data as a bytevector. +```scheme +(f:read-bytes "path/to/binary/data") +``` + +### `read-text path` +Read text from `path`. + +Return the text as a string. +```scheme +(f:read-text "path/to/file.txt") +``` + +### `read-line path` +Read a single line of text from `path`. + +Return the line as a string. It doesn't contain a newline character. + +``` +(f:read-line "path/to/file.txt") +``` + +### `read-lines path` +Read all the lines of a file. + +Returns the lines as a list of strings. +``` +(f:read-lines "path/to/file.txt") +``` ## Contributing |