So I am trying to make an ASCII chess game for Haskell. When thinking about how to represent the chesspieces I think that giving the letters different colours would be a nice way.
Thus I need someway, in the haskell code, to specify which color a certain output character should be. Is there such a package ready for me which I just have not found? Or is there some quite easy way to do it?
Or are there other suggestions on how to do this representation of chesspiececolor? My first thought of a workaround was to do wP, wB, bK for white peon, white bishop and black king but I think it looks quite cluttery.
Thanks.
You may find the ansi-terminal
package interesting. It lets you easily change the foreground colour, background colour, style, etc. For example, here is a function which will print out the string you give it in bold red, with a green background.
import System.Console.ANSI
earlyChristmas :: String -> IO ()
earlyChristmas s = do
setSGR [ SetConsoleIntensity BoldIntensity
, SetColor Foreground Vivid Red
, SetColor Background Dull Green
]
putStr s
setSGR [ Reset ]