Reputation: 13
I'm having some trouble creating a list of items in Haskell for a text based adventure game.
("cavern",
Room.Room { Room.name = "Cavern"
, Room.description = ""
, Room.directions = Map.fromList [
(North, "hall") ]
, Room.visited = False
, Room.items = [
Item.Item { Item.name = "Trident" } ]
})
Is the code and i'm trying to add multiple items to a room however nothing I've tried seems to work the closest I got was using
("cavern",
Room.Room { Room.name = "Cavern"
, Room.description = ""
, Room.directions = Map.fromList [
(North, "hall") ]
, Room.visited = False
, Room.items = [
Item.Item { Item.name = "Trident" } { Item.name = "Trident2" } ]
})
But this just made it so the last item block was the only item in the room
Upvotes: 1
Views: 85
Reputation: 70377
Assuming Item.Item
is the name of a data constructor with record syntax, you simply need to use it twice.
Room.items = [
Item.Item { Item.name = "Trident" }, Item.Item { Item.name = "Trident2" }
]
Upvotes: 5