io-manager-0.1.0.4: Skeleton library around the IO monad.
Copyright(c) Mihai Maruseac
LicenseBSD3
Maintainermihai.maruseac@gmail.com
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Training.MM.IOManager

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 = String Source #

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 -> String Source #

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

getInputFile :: Input -> Filename -> String Source #

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

writeStdOut :: Output -> String -> Output Source #

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 -> Output Source #

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 -> Output Source #

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.