Created
January 19, 2012 17:49
-
-
Save tokland/1641425 to your computer and use it in GitHub Desktop.
Some thoughts on Roy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.getProperty = function(name, obj) { | |
return obj[name]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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