moxuse / roy

Small functional language that compiles to JavaScript.

Home Page:http://roy.brianmckenna.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Roy Build Status

Roy is a small functional language that compiles to JavaScript. It has a few main features:

  • Damas-Hindley-Milner type inference
  • Whitespace significant syntax
  • Simple tagged unions
  • Pattern matching
  • Structural typing
  • Monad syntax
  • Not-horrible JS output

Usage

To compile:

make deps
make

To enter a REPL:

./roy

To compile and run a .roy file:

./roy -r examples/helloworld.roy

To compile a .roy file to .js:

./roy examples/helloworld.roy
cat examples/helloworld.js

Example

Input (test.roy):

let addTwo n =
    n + 2

console.log (addTwo 40)

Output (test.js):

var addTwo = function(n) {
    return n + 2;
}
console.log(addTwo(40))

Calling addTwo "test" will result in a compile-time error (addTwo can only take a Number).

See the examples directory for more.

License

MIT

Editor Support

Resources

About

Small functional language that compiles to JavaScript.

http://roy.brianmckenna.org/

License:MIT License


Languages

Language:JavaScript 92.1%Language:CSS 4.3%Language:HTML 3.4%Language:Makefile 0.1%Language:Shell 0.1%