【发布时间】:2010-07-22 16:52:17
【问题描述】:
我想创建一个实现 IDictionary 和 IEnumerable 的只读键控集合。采取明显的方法,我得到以下错误:
This type implements or inherits the same interface at different generic instantiations 'IEnumerable<'V>' and 'IEnumerable<KeyValuePair<'K,'V>>'. This is not permitted in this version of F#.
有没有不同的方法来实现这一点?
编辑 - 既然这似乎是 F# 不可逾越的限制,那么实现这一点的惯用方式是什么?想到的一个想法是提供返回所需数据视图的成员,例如成员 x.List : IList 和成员 x.Dict : IDictionary。对象表达式可用于提供实现。还有其他想法吗?
【问题讨论】:
标签: f#