{"action":"created","issue":{"url":"https://api.github.com/repos/thoughtbot/Argo/issues/251","labels_url":"https://api.github.com/repos/thoughtbot/Argo/issues/251/labels{/name}","comments_url":"https://api.github.com/repos/thoughtbot/Argo/issues/251/comments","events_url":"https://api.github.com/repos/thoughtbot/Argo/issues/251/events","html_url":"https://github.com/thoughtbot/Argo/issues/251","id":109317806,"number":251,"title":"Is there any way to parse a generic type `T`, conforming to `Decodable` protocol with <| operator ?","user":{"login":"AlexanderKaraberov","id":3254818,"avatar_url":"https://avatars.githubusercontent.com/u/3254818?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexanderKaraberov","html_url":"https://github.com/AlexanderKaraberov","followers_url":"https://api.github.com/users/AlexanderKaraberov/followers","following_url":"https://api.github.com/users/AlexanderKaraberov/following{/other_user}","gists_url":"https://api.github.com/users/AlexanderKaraberov/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexanderKaraberov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexanderKaraberov/subscriptions","organizations_url":"https://api.github.com/users/AlexanderKaraberov/orgs","repos_url":"https://api.github.com/users/AlexanderKaraberov/repos","events_url":"https://api.github.com/users/AlexanderKaraberov/events{/privacy}","received_events_url":"https://api.github.com/users/AlexanderKaraberov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/thoughtbot/Argo/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-01T14:59:16Z","updated_at":"2015-10-02T17:43:00Z","closed_at":null,"body":"Here is my model:\r\n\r\n```swift\r\nstruct GenericServerResponse <T where T: Encodable, T: Decodable> {\r\n    \r\n    let status: String\r\n    let errors: [String]\r\n    let debugErrors: [String]\r\n    let data: T\r\n}\r\n\r\nextension GenericServerResponse: Decodable {\r\n    \r\n    static func create\r\n        (status: String)\r\n        (errors: [String])\r\n        (debugErrors: [String])\r\n        (data: T)     -> GenericServerResponse {\r\n            \r\n            return GenericServerResponse(status: status, errors: errors, debugErrors: debugErrors, data: data)\r\n            \r\n    }\r\n    \r\n    static func decode(j: JSON) -> Decoded<GenericServerResponse> {\r\n        return GenericServerResponse.create\r\n            <^> j <|  \"status\"\r\n            <*> j <|| \"errors\"\r\n            <*> j <|| \"debug_errors\"\r\n            <*> j <|  \"data\"  //Here is an error\r\n    }\r\n}\r\n```\r\nI got error `Ambiguous reference to member <|`. I think I made some kind of stupid error here, or may be it is some kind of limitation in Swift compiler (e.g. because it doesn't support higher kinded types)? Then any possible workarounds?. The reason for this: `data` field can contain any object type which is `Decodable`, for different type of requests and I don't want to duplicate this model for every request with different `data`.\r\n\r\n`P.S` Should be marked with `question` label."},"comment":{"url":"https://api.github.com/repos/thoughtbot/Argo/issues/comments/145095385","html_url":"https://github.com/thoughtbot/Argo/issues/251#issuecomment-145095385","issue_url":"https://api.github.com/repos/thoughtbot/Argo/issues/251","id":145095385,"user":{"login":"tonyd256","id":1169797,"avatar_url":"https://avatars.githubusercontent.com/u/1169797?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyd256","html_url":"https://github.com/tonyd256","followers_url":"https://api.github.com/users/tonyd256/followers","following_url":"https://api.github.com/users/tonyd256/following{/other_user}","gists_url":"https://api.github.com/users/tonyd256/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyd256/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyd256/subscriptions","organizations_url":"https://api.github.com/users/tonyd256/orgs","repos_url":"https://api.github.com/users/tonyd256/repos","events_url":"https://api.github.com/users/tonyd256/events{/privacy}","received_events_url":"https://api.github.com/users/tonyd256/received_events","type":"User","site_admin":false},"created_at":"2015-10-02T17:43:00Z","updated_at":"2015-10-02T17:43:00Z","body":"Ya, unfortunately I think `T` is too generic to work here because Argo doesn't know what do decode that as. Would you be able to hold onto `data` as a `JSON`? Then you can decode that when the time comes to the appropriate model. Looking at your example more closely, I think that makes sense. I like how your abstracting a server response. I would just hold on to the `JSON` and then decode to the appropriate model later on down the pipeline. "}}