2017-09-29

(sph io read-write)

generic port reading/writing

part of sph-lib

rw- procedures

the type signatures of the these procedures are all similar. they take read and write procedures that have the following type signature

read :: port -> any
write :: any port ->

example

processing lines read from standard input

(port-lines-map->port (l (line) (string-reverse line)) #:handle-delim (q trim))

bindings

import name

(sph io read-write)

exports

rw-any->file

procedure

signature

read write a path ->

except file ->

description

file

applies the appropriate rw- procedure depending on data-type of a

rw-any->list

procedure

signature

read a ->

except string ->

description

list and list->list

rw-any->port

procedure

signature

read write a port ->

except string ->

description

port

rw-any->string

procedure

signature

read write a ->

except string ->

description

string

rw-file->file

procedure

signature

read write path path-2 ->

description

the target file at "path-2" is truncated or created before the writing starts

rw-file->list

procedure

signature

read path ->

rw-file->port

procedure

signature

read write path port ->

rw-file->string

procedure

signature

read write path ->

rw-file-indirect->file

procedure

signature

read write path-1 [path-2] ->

like rw-port ->

description

file but takes a path for reading from an input file

rw-list->file

procedure

signature

write a path ->

rw-list->port

procedure

signature

write a port ->

rw-list->string

procedure

signature

write a ->

rw-port->file

procedure

signature

read write port path ->

rw-port->list

procedure

signature

read port ->

rw-port->port

procedure

signature

read write port port-2 ->

rw-port->string

procedure

signature

read write port ->

rw-port-indirect->file

procedure

signature

read write port path ->

like rw-port ->

description

file but uses a temporary file to buffer all written data before it is written to the target path.

use case: read from a file for processing and write to the same file.

also known as: late-write

rw-string->file

procedure

signature

read write a path ->

rw-string->list

procedure

signature

read a ->

rw-string->port

procedure

signature

read write a port ->

rw-string->string

procedure

signature

read write a ->

sph-io-read-write-description

variable

tags: programming guile documentation library scheme sph-lib read-write sph-io-read-write