How do I clear the terminal screen in Haskell?

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


Solution 1:

:! run the shell command
:! cls under windows
:! clear under linux and OS X

Solution 2:

This is what you may be looking for:

ansi-terminal: Simple ANSI terminal support, with Windows compatibility

You can find it in Hackage and install using cabal install ansi-terminal. It specifically has functions for clearing the screen, displaying colors, moving the cursor, etc.

Using it to clear the screen is easy: (this is with GHCI)

import System.Console.ANSI

clearScreen

Solution 3:

Just press Ctrl+L (works on Windows)