Hello World in Idris

Our first program will print the classic “hello world” message. Here’s the full source code.

module Main

import IO

main : IO ()
main = putStrLn "hello world"

To run the program, you can use the following commands. Save the code in a file named Main.idr and then run it using the Idris compiler:

$ idris Main.idr -o main
$ ./main
hello world

In Idris, building the code compiles it to an executable binary. Alternatively, to compile and run in one step, you can use:

$ idris --exec main Main.idr
hello world

Now that we can run and build basic Idris programs, let’s learn more about the language.