class Fun {

    public static <M, K, V, R> BiFunction<K, V, M>
    composeTry2(final @NotNull Function<? super R, ? extends M> monadUnit,
                final @NotNull Supplier<? extends M> monadZero,
                final @NotNull ThrowingBiFunction<? super K, ? super V, ? extends R> mayThrowOnApply,
                final @Nullable BiConsumer<? super Map.Entry<? super K, ? super V>, ? super Exception> onError) {

        return (elementK, elementV) -> {
            try {
                return monadUnit.apply(mayThrowOnApply.tryApply(elementK, elementV));
            } catch (final Exception error) {
                if (onError != null) {
                    onError.accept(toEntry(elementK, elementV), error);
                }
                return monadZero.get();
            }
        };
    }

    private  Fun();

}