title: What is the difference between the reader monad and a partial function in Clojure?
body: <p><a href="http://www.leonardoborges.com/writings/" rel="nofollow">Leonardo Borges has</a> put together <a href="http://www.slideshare.net/borgesleonardo/monads-in-clojure" rel="nofollow">a fantastic presentation</a> on Monads in Clojure. In it he describes the reader monad in Clojure <a href="https://gist.github.com/leonardoborges/9344290" rel="nofollow">using the following code</a>:</p>
  
  <pre><code>;; Reader Monad
  
  (def reader-m
    {:return (fn [a]
               (fn [_] a))
     :bind (fn [m k]
             (fn [r]
               ((k (m r)) r)))})
  
  (defn ask  []  identity)
  (defn asks [f]
    (fn [env]
      (f env)))
  
  (defn connect-to-db []
    (do-m reader-m
          [db-uri (asks :db-uri)]
          (prn (format "Connected to db at %s" db-uri))))
  
  (defn connect-to-api []
    (do-m reader-m
          [api-key (asks :api-key)
           env (ask)]
          (prn (format "Connected to api with key %s" api-key))))
  
  (defn run-app []
    (do-m reader-m
          [_ (connect-to-db)
           _ (connect-to-api)]
          (prn "Done.")))
  
  ((run-app) {:db-uri "user:passwd@host/dbname" :api-key "AF167"})
  ;; "Connected to db at user:passwd@host/dbname"
  ;; "Connected to api with key AF167"
  ;; "Done."
  </code></pre>
  
  <p>The benefit of this is that you're reading values from the environment in a purely functional way. </p>
  
  <p>But this approach looks very similar to the partial function in Clojure. Consider the following code:</p>
  
  <pre><code>user=&gt; (def hundred-times (partial * 100))
  #'user/hundred-times
  
  user=&gt; (hundred-times 5)
  500
  
  user=&gt; (hundred-times 4 5 6)
  12000
  </code></pre>
  
  <p>My question is: <strong>What is the difference between the reader monad and a partial function in Clojure?</strong></p>