How do I avoid referring to all state variables when updating only a few?
问题 An idiom I use for composing a couple of procedures (with memory) is as follows: p1 :: State (Int, String) () p1 = do (a, b) <- get ... do something ... put (a', b) p2 :: State (Int, String) () p2 = do (a, b) <- get ... do something else ... put (a, b') main = do ... initializing a0 b0 ... print . flip evalState (a0, b0) . sequence $ replicate 10 p1 ++ repeat p2 However, as the number of state variable grows, this quickly gets way more verbose than necessary: p1 :: State (Int, String, Bool,