I'm new to F# and I'm trying to implement a little calculator with these interfaces... But I'm struggling with the derive part as soon as i get to f_add.
Would be nice if someone could help me out. :)
type IFunction =
interface
abstract member ToString: Unit -> String
abstract member Apply: Nat -> Nat
abstract member Derive: Unit -> IFunction
end
Since f_add
is defined in curried form (typical for F# functions), and not tupled, you need to pass the arguments with spaces, not as a tuple:
// HERE . Using comma makes that a tuple
// member self.Derive () = f_add(f.Derive (), g.Derive ()) //wrong
Instead, pass as an F# style function:
member self.Derive () = f_add (f.Derive ()) (g.Derive ())
The same issue exists in the other implementations.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.