BAM Weblog

Roy - Standard Library

Brian McKenna2011-06-26

I spent a large chunk of this week trying to create modules in Roy. I've thought of countless ways to try and implement them but none of the solutions have been very good. I have two fundamental problems:

  1. JavaScript itself doesn't support modules
  2. Roy needs static type information to be useful

To illustrate the problem, in CommonJS we do this:

var x = require('./x');
exports.a = x.y;
exports.b = 1;

In the browser we do this:

window.m = {a: window.x.y, b: 1};

How do we create a solution that imports/exports type information across both?

I don't think it's possible. I might have to resort to making the Roy compiler modal (CommonJS or bowser modes).

That problem aside. I did commit something this week - the start of a standard library:

console.log (id 1) // 1
console.log (odd 2) // false

console.log (maybe 0 id None) // 0

console.log (head (tail (replicate 10 'a'))) // a

While writing the standard library I've found a lot of holes in the type system. I'll try to fix them for next week!

Please enable JavaScript to view the comments powered by Disqus.