I'd like to do know the simplest method for adjusting a single stored value whilst hanging on to the pre existing other value. Can I directly access the value of Size, whilst carrying through the pre-existing value of Color?
data Example = Color Size
deriving (Show)
data Color = C Red Green Blue
deriving (Show)
data Size = S Small Medium Large
deriving (Show)
useExample :: Example -> String -> Example
useExample e s =
case s of
"S" -> e.Color Small
"M" -> e.Color Medium
"L" -> e.Color Large
Say I have a type with lots of fields, and a value of this type. Is it possible to create another value of this type with all but one field the same, without resorting to writing out all the fields.
This becomes critical when there are many scenarios to consider, the project I'm working on has many more than there are in this example.