Reputation: 1664
I want to create extension on SignalProducerType as below.
extension SignalProducerType{
func mapR() -> SignalProducer<[String:AnyObject], XError> {
return attemptMap { (value: [String:AnyObject]) -> Result<[String:AnyObject], XError> in
return Result(value: ["1":1])
}
}
}
XError is defined as ErrorType
public enum XError: ErrorType{
case Invalid
case Unsuccessful
}
But this won't compile and error is.
'attemptMap' produces 'SignalProducer', not the expected contextual result type 'Result<[String : AnyObject], XError>' (aka 'Result, XError>')
Upvotes: 0
Views: 264
Reputation: 4987
You are extending SignalProducerType who has generic associated types Value
and Error
, which means self is a generic type e.g. SignalProducer<Value, Error>
. So you can't call attempMap with concrete value type [String:AnyObject] and concrete error type XError.
Replace the first line extension SignalProducerType
with
extension SignalProducerType where Value == [String:AnyObject], Error == XError
Upvotes: 0