def apply_adapter(sampler, adapter):
    """ Applies an adapter to the given sampler

    Parameters
    ----------
    sampler: a sampling function to adapt.
    adapter: the adapter to apply to the sampling function.

    Returns
    -------
    sample: a sampling function
    """

    def sample():
        data = sampler()
        return adapter(data)

    return sample