How does one use ansi-wl-pprint with haskeline, without losing Windows support?
ansi-wl-pprint has two ways to output a SimpleDoc
:
(\doc -> displayS doc "") :: SimpleDoc -> String
displayIO stdout :: SimpleDoc -> IO ()
However, the documentation warns that displayS
does not work on Windows (cmd.exe
doesn't implement ANSI escape sequences?).
displayIO
doesn't use haskeline's print functions, however:
outputStr :: MonadIO m => String -> InputT m ()
outputStrLn :: MonadIO m => String -> InputT m ()
getExternalPrint :: MonadException m => InputT m (String -> IO ())
The closest thing to a solution I can see right now is:
outputPretty :: (MonadException m, MonadIO m, Pretty p) => p -> InputT m ()
outputPretty p = getExternalPrint >>= doPrint
where doc = renderPretty 0.4 80 $ pretty p
doPrint print = liftIO . print $ displayS doc ""
However, if displayS
doesn't work on Windows, I'd prefer not to use it.