我在F#中有一个界面
type IStongList = abstract member ToStringList: float * float list
而且我在制作一个float,float元组列表时遇到了麻烦.
type MyTypw = struct val L1: float val L2: float val M1: float val M2: float // . . . interface IStrongList with member this.ToStrongList = let one: float * float = (this.L1,this.M1) let two: float * float = (this.L2,this.M2) [ one two ] end
我得到的错误是:
This expression was expected to have type float * float list but here has type 'a list
我究竟做错了什么?
A float * float list
是由a float
和a 组成的元组float list
,而不是由两个float
s 组成的元组列表.为此你应该使用(float * float) list
:
type IStrongList = abstract member ToStrongList: (float * float) list
如果您更改这样的界面,其余代码将正常工作.
您的代码中也存在一些拼写错误(IStongList
→ IStrongList
和ToStringList
→ ToStrongList
)但我会将这些错误归结为转录错误.