program-0.1.0.0: Programs with Environments and Managed Resources
Copyright(c) Michael Szvetits 2021
LicenseBSD3 (see the file LICENSE)
Maintainertypedbyte@qualified.name
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Program.Writer

Description

Types and functions for handling appendable output in the environment of a Program.

Synopsis

Writer Effect

newtype Writer w Source #

A record of functions which represents the operations on an appendable output.

Constructors

Writer 

Fields

Program-based Writer

newWriter :: Monoid w => IO (Writer w, IO w) Source #

Creates a new record of functions for appendable output, backed by an IORef.

Returns the record of functions and an action which reads the accumulated output, usually used after running a corresponding Program with the Writer in its environment.

tell :: e `Has` Writer w => w -> Program e () Source #

Produces the output w. In other words, w is appended to the accumulated output.