liveBook · Manning

Tell

As explained in Learn Haskell by Example

tell is a WriterT operation that adds a value to the accumulated output.

tell adds a value to the output accumulated by WriterT while the computation continues. Its type is Monad m => w -> WriterT w m (). section 15.1.2

The collected output is combined as pieces arrive, so w typically needs Semigroup and Monoid instances. This separates reporting from the computation’s returned result. section 15.1.2

Collecting directories during traversal

With type App a = WriterT [FilePath] IO a, tell dirs records each directory list. Running runWriterT (example "foo") produces ((),["baz","bar"]).

How Learn Haskell by Example covers it

How deep it goes
Defines tell’s type and demonstrates accumulation, but does not descend into WriterT implementation internals.
Examples
Uses recursive directory traversal and synchronization log entries as concrete accumulated outputs.
What it assumes
Requires an output type that typically supplies Semigroup and Monoid instances for combining accumulated values.
What you can do after
Apply it via WriterT to record output while preserving the computation’s ordinary result.
How it connects
Connects tell with WriterT, Monoid, Semigroup, IO, and file synchronization.

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.