Skip to content

Instantly share code, notes, and snippets.

@tokland
Created January 19, 2012 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tokland/1641425 to your computer and use it in GitHub Desktop.
Save tokland/1641425 to your computer and use it in GitHub Desktop.
Some thoughts on Roy
exports.getProperty = function(name, obj) {
return obj[name];
};
// JS-interoperability library (do we do Node requires that way?)
let js = require 'js'
// Generic use of js.getProperty (type-unsafe, returns native object)
console.log (js.getProperty "length" "hi")
// Simulate a module (is there a module system in Roy?), still type-unsafe
string_length s =
js.getProperty "length" s
let String = {length: string_length}
console.log (String.length "there")
// How to use safe types with native objects?
// maybe using operator ':' à la Haskell (read "5" :: Int)?
// string_typed_length (s:String) : Number =
// (js.getProperty "length" s) : Number
// let StringTyped = {length: string_typed_length}
// roy> String.length "bye"
// 3 : Native
// roy> StringTyped.length "bye"
// 3 : Number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment