Your first program
The REPL
Section titled “The REPL”Type blue on its own to start the REPL, where you can try Blue a line at a time:
$ blueBlue 0.7.0Type an expression or a declaration, or :help for commands.blue> fn double x = x * 2double : Int -> Intblue> double 21it : Int = 42Blue worked out that double takes an Int and gives an Int; you rarely write types yourself. :type shows the type of anything, :help lists the REPL’s commands, and Ctrl-D (or :quit) leaves.
A program in a file
Section titled “A program in a file”Save this as hello.blue:
fn greet name = "Hello, " ++ name
fn main () = print (greet "Blue") print "2 + 2 is {2 + 2}"Hello, Blue2 + 2 is 4and run it:
blue run hello.blueblue run checks the whole program, then calls main. ++ joins strings, and anything in braces inside a string, like {2 + 2}, is worked out and put in its place.
To check a program without running it, and see the type of everything in it:
blue check hello.bluegreet : String -> Stringmain : Unit -> <Console> Unitmain’s type says it takes nothing ((), the Unit value), returns nothing, and uses the Console: printing is an effect, and Blue’s types say which effects a function has. A function whose type has no effects, like greet, does nothing but compute its answer.
Next: an actor that remembers.