src/runtime/party/party.c
static par_t* fmap(pony_ctx_t** ctx, closure_t* const f, par_t* in,
                   pony_type_t const * const rtype){
  fmap_s *fm = (fmap_s*) encore_alloc(*ctx, sizeof* fm);
  *fm = (fmap_s){.fn = f, .rtype=rtype};
  switch(in->tag){
  case EMPTY_PAR: return new_par_empty(ctx, rtype);
  case VALUE_PAR: return fmap_run_v(ctx, in, fm);
  case FUTURE_PAR: return fmap_run_f(ctx, in, fm);
  case PAR_PAR: {
    // TODO: may consume all the stack
    par_t* left = fmap(ctx, f, in->data.p.left, rtype);
    par_t* right = fmap(ctx, f, in->data.p.right, rtype);
    return new_par_p(ctx, left, right, &party_type);
  }
  case FUTUREPAR_PAR: return fmap_run_fp(ctx, in, fm);
  case ARRAY_PAR: return fmap_run_array(ctx, in, fm);
  default: exit(-1);
  }
}
/**
 *  fmap: (a -> b) -> Par a -> Par b
 *
 *  @param f Closure function to be called
 *  @param in Parallel collection data structure to call \p f on
 *  @param rtype The returned runtime type (ENCORE_PRIMITIVE or ENCORE_ACTIVE)
 *  @return a pointer to a new parallel collection of \p rtype runtime type
 */
> b) -> Par a -> Par b
@param f Closure function to be called
@param in Parallel collection data structure to call \p f on
@param rtype The returned runtime type (ENCORE_PRIMITIVE or ENCORE_ACTIVE)
@return a pointer to a new parallel collection of \p rtype runtime type
> b ) - > Par a - > Par b @param f Closure function to be called @param in Parallel collection data structure to call \ p f on @param rtype The returned runtime type ( ENCORE_PRIMITIVE or ENCORE_ACTIVE ) @return a pointer to a new parallel collection of \ p rtype runtime type
static par_t* fmap(pony_ctx_t** ctx, closure_t* const f, par_t* in,
                   pony_type_t const * const rtype){
  fmap_s *fm = (fmap_s*) encore_alloc(*ctx, sizeof* fm);
  *fm = (fmap_s){.fn = f, .rtype=rtype};
  switch(in->tag){
  case EMPTY_PAR: return new_par_empty(ctx, rtype);
  case VALUE_PAR: return fmap_run_v(ctx, in, fm);
  case FUTURE_PAR: return fmap_run_f(ctx, in, fm);
  case PAR_PAR: {
    par_t* left = fmap(ctx, f, in->data.p.left, rtype);
    par_t* right = fmap(ctx, f, in->data.p.right, rtype);
    return new_par_p(ctx, left, right, &party_type);
  }
  case FUTUREPAR_PAR: return fmap_run_fp(ctx, in, fm);
  case ARRAY_PAR: return fmap_run_array(ctx, in, fm);
  default: exit(-1);
  }
}
static par_t * fmap ( pony_ctx_t * * ctx , closure_t * const f , par_t * in , pony_type_t const * const rtype ) { fmap_s * fm = ( fmap_s * ) encore_alloc ( * ctx , sizeof * fm ) ; * fm = ( fmap_s ) { . fn = f , . rtype = rtype } ; switch ( in -> tag ) { case EMPTY_PAR : return new_par_empty ( ctx , rtype ) ; case VALUE_PAR : return fmap_run_v ( ctx , in , fm ) ; case FUTURE_PAR : return fmap_run_f ( ctx , in , fm ) ; case PAR_PAR : { par_t * left = fmap ( ctx , f , in -> data . p . left , rtype ) ; par_t * right = fmap ( ctx , f , in -> data . p . right , rtype ) ; return new_par_p ( ctx , left , right , & party_type ) ; } case FUTUREPAR_PAR : return fmap_run_fp ( ctx , in , fm ) ; case ARRAY_PAR : return fmap_run_array ( ctx , in , fm ) ; default : exit ( -1 ) ; } }
fmap: (a -> b) -> Par a -> Par b
  @param f Closure function to be called
  @param in Parallel collection data structure to call \p f on
  @param rtype The returned runtime type (ENCORE_PRIMITIVE or ENCORE_ACTIVE)
  @return a pointer to a new parallel collection of \p rtype runtime type
fmap : ( a - > b ) - > Par a - > Par b @param f Closure function to be called @param in Parallel collection data structure to call \ p f on @param rtype The returned runtime type ( ENCORE_PRIMITIVE or ENCORE_ACTIVE ) @return a pointer to a new parallel collection of \ p rtype runtime type
// TODO: may consume all the stack