Skip to content

Windows 10: GHCi v8.8.1 ignores 'ANSI' codes in its prompt

Summary

On Windows 10, GHCi v8.8.1 is 'ANSI escape codes-aware' but 'ANSI' codes in the GHCi prompt are not intercepted and processed and do not have the expected effect.

Steps to reproduce

>stack exec -- ghci --version
The Glorious Glasgow Haskell Compilation System, version 8.8.1

>stack exec -- ghci
GHCi, version 8.8.1: https://www.haskell.org/ghc/  :? for help
Prelude> :set prompt "\ESC[34mBlue?\ESC[39m"
[34mBlue?[39m
[34mBlue?[39mputStrLn "\ESC[34mThis is blue text, as expected.\ESC[39m"
This is blue text, as expected.
[34mBlue?[39m

In the example above, the GHCi prompt is not set to Blue? (in blue text), as expected, but to [34mBlue?[39m (the \ESC characters not printing).

Environment

  • GHC version used: 8.8.1 (also true for 8.6.5)

Optional:

  • Operating System: Windows 10
  • System Architecture: x64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information