```
foldFree f (Free as) = f as >>= foldFree f
```

@inheritdoc
192716
public function foldFree(callable $f, callable $return): FantasyLand\Monad
    {
        return $f($this->f)->bind(function (MonadFree $next) use ($f, $return) : FantasyLand\Monad {
            return $next->foldFree($f, $return);
        });
    }
215207
def compose(*funcs):
    """"""
    return lambda x: reduce(lambda v, f: f(v), reversed(funcs), x)
818779
public function with($iteration) {
        return $this
        ->fold(
            array(), 
            function($a, $f) use ($iteration) { 
                $iteration($f); 
                // As the subjacent FDirectory is lazy, we need to evaluate
                // the contents, as there might be additional computations
                // hidden.
                if (!$f->isFile()) {
                    $f->contents();
                }
                $a[] = $f; // Do not disturb the structure of
                return $a; // the directory tree.
            }
        );
    }
1086874
public function foldl(callable $closure, $initial)
    {
        $accumulator = $initial;

        foreach ($this->value as $value) {
            $accumulator = Std::call($closure, $accumulator, $value);
        }

        return $accumulator;
    }
979224
public static function each(callable $function, $input)
    {
        if ($input instanceof FoldableInterface) {
            $input->foldl(function ($acc, $x) use ($function) {
                $function($x);
            }, null);

            return;
        } elseif ($input instanceof LeftFoldableInterface) {
            $input->foldl(function ($x) use ($function) {
                $function($x);
            }, null);

            return;
        }

        static::map($function, $input);
    }
1192719
final static function s($m, $req = null) {return dfcf(function(M $m, $req = null) {
		$c = df_con_hier($m, self::class); /** @var string $c */
		return new $c($m, $req);
	}, [dfpm($m), $req]);}
1235167
public function bind(callable $function) : Monadic
    {
        return new self(function ($state) use ($function) {
            list($initial, $final) = $this->run($state);

            return $function($initial)->run($final);
        });
    }
1060317
function foldR(fn, startValue, list) {
      
   return list 
            ? fn(foldR(fn, startValue, tail(list)), head(list))
            : startValue
            ;
}
796515
public static function flattenList($a)
    {
        if (!isList($a)) {
            return $a;
        }

        do {
            $flatten = false;
            for ($i = 0, $l = sizeof($a); $i < $l; $i++) {
                if (isList($a[$i])) {
                    $flatten = true;
                    break;
                }
            }
            if (!$flatten) {
                break;
            }
            $res = [];
            for ($i = 0; $i < $l; $i++) {
                if (!isList($a[$i])) {
                    // filter empty arrays inside
                    if (!(is_array($a[$i]) && empty($a[$i]))) {
                        $res[] = $a[$i];
                    }
                } else {
                    $res = array_merge($res, (array)$a[$i]);
                }
            }
            $a = $res;
        } while ($flatten);

        return $a;
    }
776931
public final <T> T fold(Function<? super L, ? extends T> left, Function<? super R, ? extends T> right) {
		if (isLeft()) {
			return left.apply(getLeft());
		} else {
			return right.apply(getRight());
		}
	}
51799
public function foldrWithKeys(callable $closure, $initial)
    {
        return $this
            ->reverse()
            ->foldlWithKeys(
                function ($acc, $key, $x) use ($closure) {
                    return $closure($key, $x, $acc);
                },
                $initial
            );
    }
1259914
function it_obeys_the_law_of_left_identity()
    {
        // Option
        $fa = Some(42);
        $a = 1;
        $f = function(int $x): Kind { return Some(($x + 2) % 2 == 0); };
        expect($this->leftIdentity($fa, $a, $f))->toBe(true);

        // List
        $fa = ImmList(1,2,3);
        $a = 1;
        $f = function(int $x): Kind { return ImmList(($x + 2) % 2 == 0); };
        expect($this->leftIdentity($fa, $a, $f))->toBe(true);

        // Set
        $fa = ImmSet(1,2,3);
        $a = 1;
        $f = function(int $x): Kind { return ImmSet(($x + 2) % 2 == 0); };
        expect($this->leftIdentity($fa, $a, $f))->toBe(true);
    }
765822
def fold_by(fn: Callable[[T1, T2], T1], start: T1) -> Callable[[ActualIterable[T2]], T1]:
    
    return lambda collection: functools.reduce(fn, collection, start)
1212753
def optimized(code, silent=True, ignore_errors=True):
    """"""
    return constant_fold(code, silent=silent, ignore_errors=ignore_errors)
1105051
function fold(m) {
  if(isArray(m)) {
    return _array.fold(m)
  }

  if(m && isFunction(m.fold)) {
    return m.fold()
  }

  throw new TypeError('fold: Non-empty Foldable with at least one Semigroup is required')
}
263186
public function bind(callable $function) : Monadic
    {
        $concat = compose(
            function (array $list) use ($function) {
                return fold(
                    function ($acc, $item) use ($function) {
                        $acc[] = $function($item)->extract();

                        return $acc;
                    },
                    $list,
                    []
                );
            },
            partialLeft('array_merge', $this->collection)
        );

        return self::of(flatten($concat($this->collection)));
    }
966206
public function foldr(callable $closure, $initial)
    {
        return $this->reverse()->foldl(
            function ($acc, $x) use ($closure) {
                return $closure($x, $acc);
            },
            $initial
        );
    }