我很好奇如何将它从 F# 移植到 Elm:
type World =
{ Rooms: Map<RoomId, Room>
Player: Player }
RoomId、Room 之间的东西叫做泛型类型字典。
请参阅此处的上下文:https://github.com/ShalokShalom/Elchemist/blob/master/Game.fs
我读了一些关于类型变量的内容,他们能帮上忙吗?
如果是这样,如何?
感谢:D
最佳答案
Elm 的语法是类似的。
编辑 - @dogbert 关于 RoomId 在我原来的答案中没有可比性是正确的。您可以改用 String 的类型别名。
type alias RoomId = String
type alias Room =
{ id: RoomId
, details: Details
, items: List Item
, exits: Exits
}
type alias World =
{ rooms: Dict RoomId Room
, player: Player
}
关于f# - Elm 中的通用类型字典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49712062/