def eval_dist_at_powseries(phi, f):
    """
    Evaluate a distribution on a powerseries.

    A distribution is an element in the dual of the Tate ring. The
    elements of coefficient modules of overconvergent modular symbols
    and overconvergent `p`-adic automorphic forms give examples of
    distributions in Sage.

    INPUT:

    - ``phi`` - a distribution

    - ``f`` - a power series over a ring coercible into a `p`-adic field

    OUTPUT:

    The value of ``phi`` evaluated at ``f``, which will be an element in the
    ring of definition of ``f``

    EXAMPLES::

        sage: from sage.modular.btquotients.pautomorphicform import eval_dist_at_powseries
        sage: R.<X> = PowerSeriesRing(ZZ,10)
        sage: f = (1 - 7*X)^(-1)

        sage: D = OverconvergentDistributions(0,7,10)
        sage: phi = D(list(range(1,11)))
        sage: eval_dist_at_powseries(phi,f)
        1 + 2*7 + 3*7^2 + 4*7^3 + 5*7^4 + 6*7^5 + 2*7^7 + 3*7^8 + 4*7^9 + O(7^10)
    """
    nmoments = phi.parent().precision_cap()
    K = f.parent().base_ring()
    if K.is_exact():
        K = phi.parent().base_ring()
    return sum(a * K(phi.moment(i))
               for a, i in zip(f.coefficients(), f.exponents())
               if i >= 0 and i < nmoments)