Skip to content
MaisaMilena edited this page Jul 2, 2019 · 7 revisions

Using Formality Core with examples

Let's take a look into Formality Core making some simple exercises. A more deep explanation about the language can be found in Formality Core Wiki.

How to use Formality Core

  1. You must have npm installed
  2. On Terminal run npm i -g formality-core
  3. Check its installation running fmc

FormalityCore functions can be accessed by any other .fmc file in the same folder, it works like every file import the others. Despite this, only 1 def main will be executed and it'll be the last one found by the compiler. If you want different executions on main, separate the files on different folders.

Running Formality Core code

  • On Terminal, go to the directory where Formality file is.
  • To see other running options, open the Terminal and type fmc. You should be able to see a lot of options.
  • For now, to simply run the code, only use fmc main. Also, sometimes you will need to check your code on the interpreter and interaction nets (more details about this will be provided later):
  1. use interaction nets: fmc -l main
  2. use an interpreter boxed: fmc -b main

The first one, shows the code output, the data about usage of Interaction Combinators Network (inet), as the number of rewrites. Inet removes boxed values on runtime (we will talk about this later), so sometimes it may fail, showing a wrong value.

Clone this wiki locally