我写了以下
[<Measure>]
type m
[<Measure>]
type s
[<Measure>]
type v = m/s
type Vector3<[<Measure>] 'a> =
{
X : float<'a>
Y : float<'a>
Z : float<'a>
}
static member (*)
(v:Vector3<'a>,f:float<'b>):Vector3<'a*'b> =
{ X = v.X*f; Y = v.Y*f ; Z = v.Z * f}
现在我正在尝试以这种方式使用它:
let next_pos (position:Vector3<m> , velocity: Vector3<m/s> ,dt : float<s> -> Vector3<m>) =
position + (velocity * dt)
它给了我一个编译器错误,但我很确定度量单位的表达是正确的。我的错误是什么?