
-- Modes

-- | A mode, when run, extracts from an action, a value and a new mode to be used as the next action.
newtype Mode' m a = Mode {
  runMode :: m (a, Mode' m a) -- ^ The inverse of 'toMode'; converts a mode to the value and future mode pair.
  } deriving (Functor)

-- | Convert an @m (a, Mode' m a)@ to @Mode'@. The first argument is interpeted as the value of the mode and the second argument as the future Mode.
toMode :: m (a, Mode' m a) -> Mode' m a
toMode = Mode
