I have a data type to keep track of state. Let's say it looks like this:
data State = State String String Int
Several functions take a State and return a new one. For example:
convert :: State -> Int -> State
convert (State a b c) 0 = State "new" b c
convert (State a b c) 1 = State a "new" c
convert (State a b c) 2 = State a b 0
(1) When I edit the State data type (to hold an additional Int, for instance) I need to edit the pattern-matching in all functions. Is it better to use record syntax in this case?
data State = State { a :: String, b :: String, c :: Int }
convert :: State -> Int -> State
convert state 0 = State "new" (b state) (c state)
convert state 1 = State (a state) "new" (c state)
convert state 2 = State (a state) (b state) 0
Now I don't have to edit the pattern-matching when changing the data type State. The construcor calls on the right hand side suffer from the same problem though. Is there a way around this? I could define some functions to create States (only those needed be manipulated when the State constructor changes).
(2) I guess there are other ways of handling this...