How do I clear the terminal screen in Haskell?

2019-01-30 17:05发布

How can I clear a terminal screen after my user has selected an option from my application's menu?

8条回答
来,给爷笑一个
2楼-- · 2019-01-30 18:03

On Unix systems you can do System.system "clear" which just invokes the command-line utility clear. For a solution that does not depend on external tools, you'd need a library that abstracts over different terminal-types like for example ansi-terminal.

查看更多
Rolldiameter
3楼-- · 2019-01-30 18:04

Under Linux (Ubuntu at least), that's the code I use for clearing the terminal:

import qualified System.Process as SP

clearScreen :: IO ()
clearScreen = do
  _ <- SP.system "reset"
  return ()
查看更多
登录 后发表回答