2

如何在不失去 Windows 支持的情况下将ansi-wl-pprinthaskeline一起使用?

ansi-wl-pprint 有两种输出 a 的方法SimpleDoc

(\doc -> displayS doc "") :: SimpleDoc -> String
displayIO stdout :: SimpleDoc -> IO ()

但是,文档警告说displayS在 Windows 上不起作用(cmd.exe不实现 ANSI 转义序列?)。

displayIO不使用 haskeline 的打印功能,但是:

outputStr :: MonadIO m => String -> InputT m ()
outputStrLn :: MonadIO m => String -> InputT m ()
getExternalPrint :: MonadException m => InputT m (String -> IO ())

我现在能看到的最接近解决方案的是:

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 ""

但是,如果displayS在 Windows 上不起作用,我宁愿不使用它。

4

0 回答 0