Any function matching the type<p><pre><code> St -> (a, St)
</code></pre>
can viewed as `State St' parameterized over `a'. There are several behaviors that organize such functions, such as Monad which "overloads the semicolon" to work on stateful computations. Another behavior implements a stateful interface: `MonadState St'.<p><pre><code> get :: St -> (St, St)
put :: St -> (St -> ((), St))
</code></pre>
With type classes in Haskell, behaviour is type-directed so in order to reap the benefits we declare a new type.<p><pre><code> {-# Language DerivingVia #-}
{-# Language GADTSyntax #-}
-- get :: My St
-- put :: St -> My ()
newtype My a where
My :: (St -> (a, St)) -> My a
deriving (Functor, Applicative, Monad, MonadState St, MonadFix)
via State St</code></pre>