def subroutine(*effects):
    """
    Returns an effect performing a list of effects. The value passed to each
    effect is a result of the previous effect.
    """

    def subroutine(value, context, *args, **kwargs):
        d = defer.succeed(value)
        for effect in effects:
            d.addCallback(effect, context, *args, **kwargs)
        return d

    return subroutine