I can't assign names to function arguments
I can't assign names to function arguments
I'm using a record that has a function as one of its members. I find it frustrating that I can't assign names to the arguments used in the function and don't understand why I can't do that. In the code below I can use ShapeA but then it is really confusing what all those arguments to the function represent. I really want to do ShapeD but it won't compile. I can do ShapeC but then I have this weirdness of defining an interface that only has a single member. Probably the best option is ShapeB but then I have to define an extra record just so I can identify the arguments to the function.
Why can functions within interfaces take names for each argument but anonymous functions as part of records can't? Am I missing something here about the proper way to write functional code?
type Coordinate = { X:float; Y:float }
type PointChooser = {
Angle : float
PathRotation : float
Scale : float
}
type IShape =
abstract member PointAt : angle:float -> pathRotation:float -> scale:float -> Coordinate
type ShapeA = {
Name : string
Formula : float -> float -> float -> Coordinate
}
type ShapeB = {
Name : string
Formula : PointChooser -> Coordinate
}
type ShapeC = {
Name : string
Formula : IShape
}
// won't compile
type ShapeD = {
Name : string
Formula : angle:float -> pathRotation:float -> scale:float -> Coordinate
}