I am curious how to port this from F# to Elm:
type World =
{ Rooms: Map<RoomId, Room>
Player: Player }
The thing between RoomId, Room is called a generic type dictionary. See here the context: https://github.com/ShalokShalom/Elchemist/blob/master/Game.fs
I read something about type variables, can they help? If so, how?
Thanks :D
Elm's syntax would be similar.
Edit - @dogbert is right about RoomId not being comparable in my original answer. You could use a type alias of a String instead.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With