indirect enum FormExpression {
case float(Float)
case reference(String,Int)
case infix(FormExpression,String,FormExpression)
case function(String,FormExpression)
}
extension FormExpression {
static var floatParser:FormParser<FormExpression> {
return { FormExpression.float($0) }<^>float
}
}
infix operator <^> : SequencePrecedence
func <^><A,B>(lhs:@escaping(A)->B,rhs:FormParser<A>) -> FormParser<B> {
return rhs.map(lhs)
}
it displays an error
Cannot convert value of type"(Float)-> FormExpression" to expected argument type"(_)-> FormExpression"
I tried to modify it several times, also went to Google and Baidu to check, not very ideal, still do not know the solution, I still have some problems in the use of closures. So I hope some friends can solve my problem and tell me why.
my code is for practice, is the source code of functional swift, changed a little.
this is the address of the exercise project: (github.com/objcio/functional-swift) . I changed some code- let float = digit.many1.map {Float (String ($0)!}