io-manager-0.1.0.2: Skeleton library around the IO monad.

Portabilityportable
Stabilitystable
Maintainermihai.maruseac@gmail.com
Safe HaskellSafe-Inferred

Training.MM.IOManager

Contents

Description

A skeleton library to help learners of Haskell concentrate on the pure-functional aspect and let the IO be handled by the library.

Synopsis

The Filename type

type Filename = StringSource

Type of filenames.

The Input type

data Input Source

Type of values holding inputs to the program, grouped by input source.

The Output type

data Output Source

Type of values holding outputs of the program, grouped by output source.

Exported for use in main pipeline

wrapIO :: (Input -> Output -> Output) -> IO ()Source

Wraps a simple function Input -> Output -> Output in order to simplify student's usage.

Exported to be usable by students

getStdIn :: Input -> StringSource

Obtains the contents of the standard input as given to the program. Returns a String containing the input without any modification.

getInputFile :: Input -> Filename -> StringSource

Obtains the contents of an input file. Returns a String containing the input without any modification.

writeStdOut :: Output -> String -> OutputSource

Appends text to the standard output. No newline is printed at the end, the caller must handle it. Returns a new Output value, containing the appended text.

writeStdErr :: Output -> String -> OutputSource

Appends text to the standard error. No newline is printed at the end, the caller must handle it. Returns a new Output value, containing the appended text.

Note: When running the program, the standard error text is displayed after the entire text from the standard input is displayed.

writeOutputFile :: Output -> Filename -> String -> OutputSource

Appends to an output file. If the file does not exist in the Output value (this program didn't yet write in it), it is created as a new one. Returns a new Output value, containing the appended text.