Last active
September 9, 2015 20:50
-
-
Save sinelaw/29a4e4745eec1a522c75 to your computer and use it in GitHub Desktop.
optional args using polymorphic records + record field constraints
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
// foo :: { 0: Num, 1: Maybe Num } -> Num | |
function foo(a, opt_b) { | |
var b = opt_b == undefined ? 3 : opt_b; | |
return a + b; | |
} | |
// foo here inferred to have this type: | |
// RowFields r Maybe => { 0: Num | r } -> b | |
foo(3); // translated to: foo { 0 = 3 | .. } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment