HomeScheme Language

Monadic IO

The coutm function provided is designed for general purpose and has nothing ANSI-sequences specific. It is not intended for unification of side-effects and values abstraction as Oleg Kiselyov's original cout is.

Though the functions like newline will be handled properly (monadic-style), their return value (usually undesired) will be displayed. Still this is a function for monadic IO. If an argument of coutm is a lambda, then it doesn't necessary display a value, it just denotes a value to be printed under certain circumstances.

In this particular application, ANSI sequences are displayed if the variable ANSI is set to #t and the output is not redirected to file. This set of conditions and entire purpose of coutm function may be rather different, naturally.

Following the terminology of P. Wadler (and R.Descartes) coutm may be considered as "pineal gland" which connect the "mind" to the "body". In context of this package that means to display an escape sequence denoted by escape-seq.

References

O. Kiselyov. Monads, Scheme, and IO.
http://www.lh.com/~oleg/ftp/Scheme/misc.html#monadic-io

P. Wadler. Monads.
http://cm.bell-labs.com/cm/cs/who/wadler/topics/monads.html

Download

HomeScheme Language