haxetink / tink_core

Core utilities
https://haxetink.github.io/tink_core
MIT License
117 stars 33 forks source link

Promise merging trouble #118

Open postite opened 4 years ago

postite commented 4 years ago

hello !

using tink.CoreApi; doesn't have same effect as using tink.core.Promise for merging.

when using only tink.CoreApi; the method and(p1:A,p2:B) generates Pair<Outcome,Error>,Outcome,Error>> and not Pair<A,B> as intended.

ex:

using tink.CoreApi;
//using tink.core.Promise;
class Prom{

    function new(){
      trace( "olé");
  var p1= Promise.lift("hop");
  var p2=Promise.lift('hip');

  (p1 && p2).next(pair->{
     $type( pair.a);//String
     pair;  
  })
  .tryRecover(e->e)
  .handle(n->n);

  p1.and(p2).next(pair->{
     $type( pair.a);--------------------//tink.Outcome<String, tink.Error>
     pair;  
  })
  .tryRecover(e->e)
  .handle(n->n);

  Promise.and(p1,p2).next(pair->{
     $type( pair.a); //String
     pair;  
  })
  .tryRecover(e->e)
  .handle(n->n);

}

}

don't know if it is by design or what . but it is confusing . just sayin ' bye.