                 }
                 return try marshaledJSON.value(for: key)
             })
-                .mapError { Error.createMarshalError($0) }
+                .mapError { Error.createMarshalError($0 as! MarshalError) }
         }
     }
 }

                    return try Model.init(object: marshaledJSON)
                }
            })
                .mapError { Error.createMarshalError($0) }
        }
    }
    

     */
    public func mapResponse<Model>(forKey key: KeyType? = nil) -> Signal<[Model], Error> where Model: Unmarshaling {
        return signal.attemptMap { json in
            return Result(catching: {
                if ACKReactiveExtensionsConfiguration.allowMappingOnMainThread == false {
                    assert(Thread.current.isMainThread == false, "Mapping should not be performed on main thread!")
                }
                
                do {
                    if let key = key, let marshaledJSON = json as? MarshaledObject {
                        return try marshaledJSON.value(for: key)
                    }
                    else if let marshaledArray = json as? [MarshaledObject] {
                        return try marshaledArray.map(Model.init)
                    }
                    else {
                        throw MarshalError.typeMismatch(expected: MarshaledObject.self, actual: type(of: json))
                    }
                }
            })
                .mapError { Error.createMarshalError($0 as! MarshalError) }
        }
    }
    
