Last active
August 29, 2015 14:10
-
-
Save sinelaw/81ba553a5635d89c9973 to your computer and use it in GitHub Desktop.
inference
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
// (c -> c) | |
// c | |
var id = function(x) { return x; }; | |
// (i -> i) | |
// TNumber | |
var num = id(3); | |
// (n -> n) | |
// TString | |
var str = id('a'); | |
//(r -> r) | |
id; | |
//TNumber | |
num; | |
//TString | |
str; | |
//({length: ad, ...} -> {len: ad, obj: {length: ad, ...}}) | |
function f(x) { | |
// {len: ad, obj: {length: ad, ...}} | |
// ab | |
// ag | |
var len = x.length; | |
// {len: ad, obj: {length: ad, ...}} | |
// {length: ad, ...} | |
// ad | |
return { obj: x, len: len }; | |
} | |
// ({length: am, ...} -> {len: am, obj: {length: am, ...}}) | |
// {len: TNumber, obj: {length: TNumber, moshe: TNumber, ...}} | |
// {length: TNumber, moshe: TNumber} | |
// TNumber | |
// TNumber | |
var y = f({ moshe: 3, length: 4 }); | |
// ({length: at, ...} -> {len: at, obj: {length: at, ...}}) | |
// {len: TString, obj: {length: TString, ...}} | |
// {length: TString} | |
// TString | |
var z = f({ length: 'a' }); | |
//({length: b`, ...} -> {len: b`, obj: {length: b`, ...}}) | |
f; | |
//{len: TNumber, obj: {length: TNumber, moshe: TNumber, ...}} | |
y; | |
//{len: TString, obj: {length: TString, ...}} | |
z; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment