I like to annotate output, using something like the following:
annotStyle[t_] := Text@Style[t, Darker@Blue, Larger]
Format[annot[t_][x_]] := Row[{annotStyle[t], annotStyle[": "], x}]
(data = Array[RandomReal, 10]) // annot@"Ten random numbers"
{Min@data, Max@data} // annot@Range
Mean@data // annot@μ
Median@data // annot@Median
Variance@data // annot@Variance
Sqrt@%[[1]] // annot@"Standard deviation"
The downside is that annotating changes the value of the output. Is there some way of avoiding this, so that, for example, in the first line of the example I don't need parentheses and in the last line of the example, I don't need to use [[1]]?
Specifically, if possible, I'd like
x // annot@tto display as t: x, but have the value of x, for any expression x.
As I've put this question together, I've realised that
annot[t_][x_] := (Print[annotStyle[t], annotStyle[": "], x]; x;)
almost does what I want and is better than my previous attempt. Is there a way of getting exactly what I want?