A State Monad is a function that takes a state s and produces an output (a, s). Here, a is the result of monadic computation, and in all monad steps, the state s is threaded through each step. This is illustrated in the following diagram:

During the monadic bind operations, the result of the previous operation is taken and is fed into a function that produces the next output, as shown in the preceding diagram.
It is important to note two specific operations that are defined in the context of the State Monad. These operations are get and put, used for getting the current state and saving a new state, respectively.
In the get operation, we will create the State Monad function in such a way that state is the result of the monad:
get :: State s s
get = let stateFunc \s -> (s, s)
in State stateFunc
Similarly, in the put operation, we will create a State Monad function in such a way that the given input replaces the current state. In this case, we will produce the void() output:
put :: s -> State s ()
put newstate = let stateFunc \_ -> ((), newstate)
in State stateFunc