puffnfresh/roy
Small functional language that compiles to JavaScript.
{ "createdAt": "2011-11-24T21:56:31Z", "defaultBranch": "master", "description": "Small functional language that compiles to JavaScript.", "fullName": "puffnfresh/roy", "homepage": "http://roy.brianmckenna.org/", "language": "JavaScript", "name": "roy", "pushedAt": "2014-03-16T20:22:09Z", "stargazersCount": 841, "topics": [], "updatedAt": "2025-08-25T14:58:30Z", "url": "https://github.com/puffnfresh/roy"}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
To compile:
make depsmakeTo enter a REPL:
./royTo compile and run a .roy file:
./roy -r examples/helloworld.royTo compile a .roy file to .js:
./roy examples/helloworld.roycat examples/helloworld.jsExample
Section titled “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
Section titled “License”MIT
Editor Support
Section titled “Editor Support”Resources
Section titled “Resources”- Roy website: http://roy.brianmckenna.org/
- Roy Google Group: http://groups.google.com/group/roylang
- Roy docs: http://guide.roylang.org/
- Roy Twitter: http://twitter.com/roylangjs
- Bitbucket repo: https://bitbucket.org/puffnfresh/roy
- GitHub repo: https://github.com/puffnfresh/roy
- Brian’s blog: http://brianmckenna.org/
- altJS channel: [irc://irc.freenode.net/altJS]!(irc://irc.freenode.net/#altJS)
- roy channel: [irc://irc.freenode.net/roy]!(irc://irc.freenode.net/#roy)
