Skip to content

Instantly share code, notes, and snippets.

@frabbit
Last active January 1, 2016 14:29
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 frabbit/8158220 to your computer and use it in GitHub Desktop.
Save frabbit/8158220 to your computer and use it in GitHub Desktop.
TCP in Haxe
using Using;
class Using {
public static function fmap <M,A,B>(x:Of<M, A>, f:A->B, functor:Functor<M>):M<B> {...}
}
var x : Of<Map<Int, In>, String> = [ 1 => "foo" ];
x.| // completion (field access) here (Map functions like exists, get etc. and from using fmap, because we "follow" first (because lifting is nonambigious here, because we always apply the In type from the right)
var x : Of<Map<In,In>, Int, String> = [ 1 => "foo">];
x.| // completion (field access) same as before because unwrapping and wrapping is right to left and thus nonambigious.
var x : Of<Map<In, String>, Int> = [ 1 => "foo" ];
x.| // completion (field access) here? (currently only fmap, because if we "follow" the Of type we get Map<Int,String> and we loose the information how it was lifted before)
// consider if Map has already an instance field fmap in that case in the first 2 examples the instance field would be used in the third the using field, because the type is not reduced to Map<Int,String>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment