Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function concat(FantasyLand\Semigroup $value)
 {
     if ($value instanceof self) {
         return self::of($this->value . $value->extract());
     }
     throw new TypeMismatchError($value, self::class);
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function concat(FantasyLand\Semigroup $value)
 {
     if ($value instanceof self) {
         return self::of($value->reduce(function ($accumulator, $item) {
             $accumulator[] = $item;
             return $accumulator;
         }, $this->extract()));
     }
     throw new TypeMismatchError($value, self::class);
 }
Exemplo n.º 3
0
/**
 * concatM :: a -> a -> a
 *
 * @param Semigroup $a
 * @param Semigroup $b
 *
 * @return Semigroup
 */
function concatM(Semigroup $a, Semigroup $b)
{
    return call_user_func_array(curryN(2, function (Semigroup $a, Semigroup $b) {
        return $a->concat($b);
    }), func_get_args());
}