Here I've learned about System.Console.ANSI, and at that doc page I read of the "strawberry" flavour functions, of which I read that
has a
Stringtype and just consists of an escape code which can be added to any other bit of text before being output.
which feels just what I want in pure code, a way to take a String and wrap it somehow in escape sequences, so that when that String finds its way in the IO monad and will printed in the terminal, it gets printed, say, in red.
How can I use the aforementioned module for this?
Clicking on the Example.hs link gives a 404.
The "strawberry" functions are the ones that end in the
Codesuffix.Note that they don't transform
Stringvalues. They simply produceStringvalues that, when output to an ANSI terminal, perform the desired action (changing the color, moving the cursor, whatever). So, for example, you can define a pureStringvalue by concatenating codes and plain text:and write it to the console in
mainor some otherIOfunction:A full sample program: