Created
December 17, 2012 12:24
-
-
Save anonymous/4317927 to your computer and use it in GitHub Desktop.
Partial Application (PA) Proposal for Haxe
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
// - Implicit and explicit PA (via partial function) | |
// - Implicit as default usage, explicit for corner cases, where meaning is ambigous | |
// - Explicit PA can handle all cases that implicit PA can handle + corner cases | |
function foo(x:Array<Int>, ?a:Int, ?b:Int):Void; | |
// Implicit Explicit Type | |
foo(_) <=> foo.partial(_) // Array<Int>->Void | |
foo(_,_) <=> foo.partial(_,_) // Array<Int>->?Int->Void | |
foo(_,_,_) <=> foo.partial(_,_,_) // Array<Int>->?a:Int->?b:Int->Void | |
foo.partial([]) // Void->Void, implicit PA not available because foo([]) is ambigious | |
foo([], _,_) <=> foo.partial([],_,_) // ?a:Int->?b:Int->Void | |
function bar(?a:Int, ?b:Int):Void; | |
bar.partial() // Void->Void, implicit PA not available because bar() is ambigious | |
bar(_) <=> bar.partial(_) // ?a:Int->Void | |
bar(_,_) <=> bar.partial(_,_) // ?a:Int->?b:Int->Void | |
function fooBar(?a:Int):Void; | |
fooBar.partial() // Void->Void, implicit PA not available because fooBar() is ambigious | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment