-- | Enable a 'Flag' for a given 'ProgramState'.
addFlag :: IORef ProgramState -> Flag -> IO ()
addFlag ps f = do
  p <- get ps
  ps $$! p & flags %~ (\fl -> if f `elem` fl then fl else f : fl)

-- | Clear a 'Flag' from the 'ProgramState'
addFlag :: IORef ProgramState -> Flag -> IO ()
addFlag ps f = do
  p <- get ps
  ps $$! p & flags %~ (\fl -> if f `elem` fl then fl else f : fl)

-- | Clear a 'Flag' from the 'ProgramState'
addFlag ps f = do
  p <- get ps
  ps $$! p & flags %~ (\fl -> if f `elem` fl then fl else f : fl)

-- | Clear a 'Flag' from the 'ProgramState'