lukewilliamboswell/roc-ansi-escapes provides some helpers to print pretty colors to the terminal using ANSI escape codes.
app "example"
packages {
cli: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br",
pkg: "https://github.com/lukewilliamboswell/roc-ansi-escapes/releases/download/0.1.1/cPHdNPNh8bjOrlOgfSaGBJDz6VleQwsPdW0LJK6dbGQ.tar.br",
}
imports [cli.Stdout, pkg.Color.{ fg }]
provides [main] to cli
main =
[
"The ",
"GREEN" |> Color.fg Green,
" frog, the ",
"BLUE" |> Color.fg Blue,
" bird, and the ",
"RED" |> Color.fg Red,
" ant shared a leaf.",
]
|> Str.joinWith ""
|> Stdout.line
I was going through some older stuff I had done and thought I might make this into a package for people to use as it could be fun for the Advent of Code.
Screenshot-2023-11-03-at-15.25.06.png
Screenshot-2023-11-03-at-15.28.20.png
Very clean API!
It occurs to me that this might be a case where being able to write string literals inside a string interpolation could come in handy!
E.g:
"The \("GREEN" |> Color.fg Green) frog"
that already works, if desired :big_smile:
Last updated: Jul 06 2025 at 12:14 UTC