Created
September 12, 2015 20:32
-
-
Save soupi/3d73e40903d1f6cc123b to your computer and use it in GitHub Desktop.
ansi-terminal colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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