Playing with the REPL
The documentation that you're reading is a design document where most of the features you're reading are yet to be implemented. Check the Note on the Docs
Even though NeoHaskell is a compiled language, it provides an interpreted
mode which is much faster for the development process. In any moment, you
neo run:repl and it will start an interactive console where you
can checkout small pieces of NeoHaskell code.
When you run the command, it will start, what's called in programmer jargon, a REPL (Read-Eval-Print-Loop). A REPL will do the following algorithm:
- Read the code you wrote
- Evaluate (execute) it
- Print the result
- Loop back to 1
Let's fire up
This is the prompt of the REPL. It's waiting for you to write some code. Let's write our first hello world program!
neo> print "Hello World!"
neo> 1 + 1
neo> 2 * 2
neo> 7 ** 20
Whoops, the last number is a bit too big.
This is because
** is the exponentiation operator.
It's the same as writing in math.
Anyway, to quit the REPL, you can press
Ctrl + C or write
Exploring the REPL commands
At any time, you can write
:help to see the list of commands available.
Don't worry too much about them if they seem a bit overwhelming. You'll learn them as you go.
In the next sections, we will start trying NeoHaskell from the REPL.