   default/effect free context.
 
   This is multiarity function that with arity pure/1
-  it uses the dynamic scope for resolve the current
-  context. With pure/2, you can force specific context
+  it uses the dynamic scope to resolve the current
+  context. With pure/2, you can force a specific context
   value."
   ([v]
      (p/pure *m-context* v))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn get-state
  "Return State instance with computation that returns
  the current state."
  []
  (-> (fn [s] (t/pair s s))
      (t/state-t)))

(defn put-state
  "Return State instance with computation that replaces
  the current state with specified new state."
  [newstate]
  (-> (fn [s] (t/pair s newstate))
      (t/state-t)))

(defn swap-state
  "Return State instance with computation that applies
  specified function to state and return the old state."
  [f]
  (-> (fn [s] (t/pair s (f s)))
      (t/state-t)))

(defn run-state
  "Given a State instance, execute the
  wrapped computation and return Pair
  instance with result and new state.

    (def computation (mlet [x (get-state)

  "Given a State instance, execute the
  wrapped computation and return the resultant
  state.
  Equivalent to taking the second value of the pair instance
  returned by `run-state` function."
  [state seed]
  (second (run-state state seed)))
