from typing import Callable


def assert_that_with_message(input_to_message: Callable, f: Callable):
    """Assert a function `f` on the input, printing the output of `input_to_message(input)` if assertion is False.

    >>> assert_that_with_message(just("Input is not 2!"), equals(2))(2)
    2
    >>> assert_that_with_message(just("Input is not 2!"), equals(2))(3)
    "Output is not 2!"
    """

    def assert_that_f(inp):
        assert f(inp), input_to_message(inp)
        return inp

    return assert_that_f