I have this record:
data Ship = CShip {Planet::String}
deriving Show
spaceship = CShip {Planet = "alphaCentauriBb"}
but I want to change the String on Planet. for example:
Planet = "alphaCentauriCc"
Is there a way to do this?
You can use the record update syntax to update the value of a field. This will create a new record value with the same field values as the old ones except for the updated fields.
newSpaceship = spaceship {planet = "alphaCentauriCc"}
Note that field names must be lowercase.