Skip to content

Instantly share code, notes, and snippets.

@soupi
Created September 12, 2015 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soupi/3d73e40903d1f6cc123b to your computer and use it in GitHub Desktop.
Save soupi/3d73e40903d1f6cc123b to your computer and use it in GitHub Desktop.
ansi-terminal colors
module Colors where
import qualified System.Console.ANSI as ANSI
main :: IO ()
main = putStrLn text
text :: String
text =
concat
["Here is the color ", withRed "Red", " And"
,"\nhere is the color ", withBlue "Blue"
]
-- Colors
withColor :: ANSI.Color -> String -> String
withColor color string =
concat
[ANSI.setSGRCode [ANSI.SetColor ANSI.Foreground ANSI.Vivid color]
,string
,ANSI.setSGRCode [ANSI.Reset]
]
withRed, withBlue, withYellow, withGreen, withCyan :: String -> String
withRed = withColor ANSI.Red
withBlue = withColor ANSI.Blue
withCyan = withColor ANSI.Cyan
withYellow = withColor ANSI.Yellow
withGreen = withColor ANSI.Green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment