def for_model(typ):
    """Decorate a factory that returns a `Mapping` type in order to coerce it into the `typ`.

    This decorator is only invoked in the context of model factory usage. The intent is that
    a factory function could be more generally useful, such as to create API inputs, that
    also happen to correspond to the creation of a model when invoked during a test.

    Examples:
        >>> class Model:
        ...     def __init__(self, **kwargs):
        ...         self.kw = kwargs
        ...
        ...     def __repr__(self):
        ...         return f"Model(a={self.kw['a']}, b={self.kw['b']}, c={self.kw['c']})"

        >>> @for_model(Model)
        ... def new_model(a, b, c):
        ...     return {'a': a, 'b': b, 'c': c}

        >>> new_model(1, 2, 3)
        {'a': 1, 'b': 2, 'c': 3}
        >>> new_model.for_model(1, 2, 3)
        Model(a=1, b=2, c=3)
    """

    def wrapper(fn):
        def for_model(*args, **kwargs):
            result = fn(*args, **kwargs)
            return typ(**result)

        fn.for_model = for_model
        return fn

    return wrapper