Online Haskell Compiler
Compile and run Haskell online with GHC 9.12. Write a program with a main function, press Run, and GHC builds it and starts it, with type errors shown by line if the build fails. Programs can read input with getLine, and the libraries that come with GHC, such as containers and text, are ready to import.
How to run Haskell code online
- This page opens with Haskell selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
GHC 9.12 on Online IDE
- Your program is compiled with GHC (ghc -O0) and starts in main.
- Output shows line by line, as in a terminal, so after putStr call hFlush stdout (import System.IO) to show a prompt before getLine waits.
- getLine reads a line of input, and readMaybe from Text.Read turns it into a number without crashing on other text.
- The libraries that come with GHC are available, such as base, containers, text, bytestring, mtl and transformers, but Hackage packages are not.
Example: a Haskell program that reads input
import System.IO
import Text.Read (readMaybe)
main :: IO ()
main = do
putStr "Enter a whole number: "
hFlush stdout
line <- getLine
case readMaybe line :: Maybe Int of
Just n | n > 0 -> putStrLn ("Divisors of " ++ show n ++ ": " ++ show [d | d <- [1 .. n], n `mod` d == 0])
_ -> putStrLn "Please enter a whole number above zero."
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which Haskell compiler does Online IDE use?
GHC 9.12 on Linux, compiling with ghc -O0.
Why does my prompt appear after I type?
GHC holds output in a buffer, so text from putStr can wait there while getLine reads. Import System.IO and call hFlush stdout after the prompt, or put hSetBuffering stdout NoBuffering at the start of main.
Can a Haskell program read input?
Yes. Use getLine, then type into the output panel while the program waits and press Enter.
Can I use packages from Hackage?
No. The libraries that come with GHC, such as containers, text, bytestring, mtl and transformers, work. Hackage packages are not installed and programs cannot download them.
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.