BAM Weblog

Roy Improvements

Brian McKenna — 2011-10-02

A few people expressed interest in Roy this week. One person had some feature requests so I started working on it again after a delay of over 2 months.

The with keyword

Roy is built on the idea of structural typing. Up until now Roy didn’t have a nice way of extending structures - users had to do this:

let addWorldField o = {hello: o.hello, world: false}

// type is: Function({hello: Boolean},{hello: Boolean, world: Boolean})

console.log (addWorldField {hello: true})

Pretty ugly. My solution was steal the with keyword from Yeti:

console.log (addWorldField {hello: true} with {world: false})

Bug fixes

Along with implementing the with keyword, I fixed some more bugs.

A huge one that had been annoying me for a long time, was a problem with type-checking tags:

// Fixed bug with unification over tags
console.log (Some 1)
console.log (Some "Test")

When using the REPL or running .roy files with the ‘-r’ flag, the standard library wasn’t imported.


Coming up next in Roy:

  • Mutable references
  • Deep pattern matching

Hopefully I’ll have even more to show next week!

Please enable JavaScript to view the comments powered by Disqus.