ANSI terminal support for Haskell, with Windows compatibility
Haskell
117
312 commits
updated Jan 22, 2026
Haskell packages together providing support for 'ANSI' control character sequences for terminals on Unix-like operating systems and Windows
'ANSI' terminal escape code support for Haskell, which allows:
If you like this, you may be interested in ansi-wl-pprint, which provides a pretty-printer that can construct strings containing 'ANSI' colorisation.
Not all 'ANSI' escape codes are supported by this library but most (if not all) of the popular ones that are well-supported by terminal software are, including:
setSGRclearFromCursorToScreenEnd,
clearFromCursorToScreenBeginning, clearScreen,
clearFromCursorToLineEnd, clearFromCursorToLineBeginning and
clearLinehideCursor and showCursorcursorUp, cursorDown, cursorForward and
cursorBackwardcursorUpLine and cursorDownLinesetCursorColumn and setCursorPositionsaveCursor,
restoreCursor and reportCursorPositionenableLineWrap and disableLineWrapscrollPageUp and scrollPageDownsetTitleEach supported escape code or family of codes has a corresponding function that comes in three variants:
IO variant that doesn't take a Handle and just applies the
escape code to stdout and any terminal attached to itIO variant similar to above, but which takes a Handle to which the
escape code should be appliedString variant that returns a literal string that should be
included to get the effect of the code.A full example is available, but for a taste of how the library works try the following code:
import System.Console.ANSI
import System.IO (stdout)
main :: IO ()
main = do
stdoutSupportsANSI <- hNowSupportsANSI stdout
if stdoutSupportsANSI
then do
setCursorPosition 5 0
setTitle "ANSI Terminal Short Example"
setSGR [ SetConsoleIntensity BoldIntensity
, SetColor Foreground Vivid Red
]
putStr "Hello"
setSGR [ SetConsoleIntensity NormalIntensity
, SetColor Foreground Vivid White
, SetColor Background Dull Blue
]
putStrLn "World!"
else
putStrLn "Standard output does not support 'ANSI' escape codes."

Haddock documentation is available at Hackage
(ansi-terminal)
and
(ansi-terminal-types).
The library was originally written by Max Bolingbroke
Mike Pilgrem and Roman Cheplyaka are the primary maintainers.
Oliver Charles is the backup maintainer. Please get in touch with him if the primary maintainers cannot be reached.
Haskell
96.1%
C
2.7%
Shell
1.1%
ANSI terminal support for Haskell, with Windows compatibility
Haskell
117
312 commits
updated Jan 22, 2026
Haskell packages together providing support for 'ANSI' control character sequences for terminals on Unix-like operating systems and Windows
'ANSI' terminal escape code support for Haskell, which allows:
If you like this, you may be interested in ansi-wl-pprint, which provides a pretty-printer that can construct strings containing 'ANSI' colorisation.
Not all 'ANSI' escape codes are supported by this library but most (if not all) of the popular ones that are well-supported by terminal software are, including:
setSGRclearFromCursorToScreenEnd,
clearFromCursorToScreenBeginning, clearScreen,
clearFromCursorToLineEnd, clearFromCursorToLineBeginning and
clearLinehideCursor and showCursorcursorUp, cursorDown, cursorForward and
cursorBackwardcursorUpLine and cursorDownLinesetCursorColumn and setCursorPositionsaveCursor,
restoreCursor and reportCursorPositionenableLineWrap and disableLineWrapscrollPageUp and scrollPageDownsetTitleEach supported escape code or family of codes has a corresponding function that comes in three variants:
IO variant that doesn't take a Handle and just applies the
escape code to stdout and any terminal attached to itIO variant similar to above, but which takes a Handle to which the
escape code should be appliedString variant that returns a literal string that should be
included to get the effect of the code.A full example is available, but for a taste of how the library works try the following code:
import System.Console.ANSI
import System.IO (stdout)
main :: IO ()
main = do
stdoutSupportsANSI <- hNowSupportsANSI stdout
if stdoutSupportsANSI
then do
setCursorPosition 5 0
setTitle "ANSI Terminal Short Example"
setSGR [ SetConsoleIntensity BoldIntensity
, SetColor Foreground Vivid Red
]
putStr "Hello"
setSGR [ SetConsoleIntensity NormalIntensity
, SetColor Foreground Vivid White
, SetColor Background Dull Blue
]
putStrLn "World!"
else
putStrLn "Standard output does not support 'ANSI' escape codes."

Haddock documentation is available at Hackage
(ansi-terminal)
and
(ansi-terminal-types).
The library was originally written by Max Bolingbroke
Mike Pilgrem and Roman Cheplyaka are the primary maintainers.
Oliver Charles is the backup maintainer. Please get in touch with him if the primary maintainers cannot be reached.
Haskell
96.1%
C
2.7%
Shell
1.1%