API for monadic-io-streams
- ()
by Konrad Hinsen
Full namespace name:
clojure.contrib.monadic-io-streams
Overview
Monadic I/O with Java input/output streams
Defines monadic I/O statements to be used in a state monad
with an input or output stream as the state. The macro
monadic-io creates a stream, runs a monadic I/O statement
on it, and closes the stream. This structure permits the
definition of purely functional compound I/O statements
which are applied to streams that can never escape from the
monadic statement sequence.
Public Variables and Functions
flush
function
Usage: (flush)
Flush
Source
print
function
Usage: (print obj)
Print obj
Source
println
function
Usage: (println)
(println obj)
Print obj followed by a newline
Source
read-char
function
Usage: (read-char)
Read a single character
Source
read-line
function
Usage: (read-line)
Read a single line
Source
read-lines
function
Usage: (read-lines)
Read all lines and return them in a vector
Source
skip-chars
function
Usage: (skip-chars n)
Skip n characters
Source
with-io-streams
function
Usage: (with-io-streams io-specs statement)
Open one or more streams as specified by io-spec, run a monadic
I/O statement on them, and close the streams. io-spec is
a binding-like vector in which each stream is specified by
three element: a keyword by which the stream can be referred to,
the stream mode (:read or :write), and a stream specification as
accepted by clojure.java.io/reader (mode :read) or
clojure.java.io/writer (mode :write). The statement
is run on a state which is a map from keywords to corresponding
streams. Single-stream monadic I/O statements must be wrapped
with clojure.contrib.monads/with-state-field.
Source
with-reader
function
Usage: (with-reader reader-spec statement)
Create a reader from reader-spec, run the monadic I/O statement
on it, and close the reader. reader-spec can be any object accepted
by clojure.java.io/reader.
Source
with-writer
function
Usage: (with-writer writer-spec statement)
Create a writer from writer-spec, run the monadic I/O statement
on it, and close the writer. writer-spec can be any object accepted
by clojure.java.io/writer.
Source
write
function
Usage: (write text)
Write text (a string)
Source