我需要一组独特的记录。但是Elm Core的Set
将集合成员限制为comparable
:
import Set exposing (Set)
mySet = Set.empty
Set.insert {name="Foo"} mySet
-- TYPE MISMATCH ----------------------------------------------------------- elm
The 1st argument to `insert` is not what I expect:
6| Set.insert {name="Foo"} mySet
^^^^^^^^^^^^
This argument is a record of type:
{ name : String }
But `insert` needs the 1st argument to be:
comparable
Hint: Only ints, floats, chars, strings, lists, and tuples are comparable.
你如何在榆树制作一套唱片?
使用标准库,您不能。如“提示”中所述,您可以使用元组,但这些仅限于0.19中的3元组。
所以,我认为你最好的选择是使用https://package.elm-lang.org/packages/Gizra/elm-all-set/latest/EverySet