Using pure can't compile using Swift 3
juvs opened this issue · 2 comments
juvs commented
We migrate our code from Swift 2 to 3, but we get errors in structs that use "pure" function o set default values when the resulting transformation return nil values...
Error Messages
Cannot convert value of type 'Decoded<(String?) -> Carril>' to expected argument type 'Decoded'
Sample JSON
{
"id": 1,
"nombre": "Test",
"descripcion": "None"
}
Models
import Argo
import Curry
import Runes
public struct Carril {
let id: Int
let nombre: String
let descripcion: String?
let ubicacion: Ubicacion?
let tarifa: Double?
let tipo: String?
}
extension Carril: Argo.Decodable {
public static func decode(_ j: JSON) -> Argo.Decoded<Carril> {
let f = curry(Carril.init)
return f
<^> j <| "id"
<*> j <| "nombre"
<*> j <|? "descripcion"
<*> j <|? "ubicacion"
<*> j <|? "costoAuto" <|> pure(0)
<*> j <|? "tipo"
}
}
Argo Version
Argo 4.1.2
Dependency Manager
Cocoapods
gfontenot commented
Hey, sorry for the delay on this. Is this still an issue for you? My assumption would be precedence levels requiring some parens but I'm not sure why that would have changed with a new version of Swift.
gfontenot commented
I'm going to go ahead and close this due to inactivity but please feel free to reopen if this is still an issue.