 // MARK: - Response API
 
 extension ServiceTask {
+    /// A closure type alias for a result transformation handler.
+    public typealias ResultTransformer = Any? -> ServiceTaskResult
+
     /**
      Add a response handler to be called on background thread after a successful
      response has been received.

// MARK: - Error Handling

extension ServiceTask {
    /**
    Add a response handler to be called if a request results in an error.
    

        return self
    }
    
    /**
     Add a response handler to transform a (non-error) result produced by an earlier
     response handler.

     The handler can return any type of service task result, `.Empty`, `.Value` or
     `.Error`. The result is propagated to later response handlers.

     - parameter handler: Transformation handler to execute.
     - returns: Self instance to support chaining.
     */
    public func transform(handler: ResultTransformer) -> Self {
        handlerQueue.addOperationWithBlock {
            guard let taskResult = self.taskResult else {
                return
            }

            switch taskResult {
            case .Failure(_):
                return // bail out; do not run this handler

            case .Empty:
                self.taskResult = handler(nil)

            case .Value(let value):
                self.taskResult = handler(value)
            }
        }
        
        return self
    }

    /**
     Add a handler that runs on the main thread and is responsible for updating 
     the UI with a given value. The handler is only called if a previous response 
