Hello, World!

This is the “Hello, World!” in Formality:

import Base@0

main : Output
  print("Hello, world!")

Save this file as hello.fm.

Running (debug)

To run it, type fm hello/main. This will evaluate main using an interpreter in debug mode and output "Hello, world!".

Running (fast)

To run it with the interaction-net runtime, type fm -o hello/main. This will be faster, but you’ll lose information like variable names and logs.


To type-check it, type fm -t hello/main. This will check if the program’s type is correct and print it (in this case, Output). If the type is incorrect, it will print an error message. For example, if you change "Hello, world!" to 7, it will print:

Type mismatch.
- Found type... Number
- Instead of... String
- When checking 7
- On line 4, col 9, file _.fm:
  1| import Base@0
  3| main : Output
  4|   print(7)

Because 7 is a Number, but the print function expects a String.