Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

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
  • Compile-time meta-programming
  • 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

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/pufuwozu/roy
  • Brian's blog: http://brianmckenna.org/
  • altJS channel: irc://irc.freenode.net/altJS

Recent activity

Brian McKenna

Brian McKenna pushed 3 commits to puffnfresh/roy

495b2cc - Attribute each node with its own type, not the whole module's type
71ab2b8 - Fix bug where patterns would add assumption for 'undefined'
9d8e717 - Fix bug with sequencing 'do' and 'match' nodes
Brian McKenna

Brian McKenna pushed 7 commits to puffnfresh/roy

7a73a88 - Added explicit error handling for null and undefined types.
d6d3d41 - "npm test" now runs "grunt jison jasmine" instead of "grunt jasmine".
4413b8b - Infer type-class dictionary for direct function calls
fba9a42 - Remove unused 4th catamorphism argument on constraints
904f611 - Add current state of constraint based inference
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.