title: Eliminating my explicit state passing via like, monads and stuff
body: <p>I'm working through the book <em>Land of Lisp</em> in F# (yeah weird, I know). For their first example text adventure, they make use of global variable mutation and I'd like to avoid it. My monad-fu is weak, so right now I'm doing ugly state passing like this:</p>
  
  <pre><code>let pickUp player thing (objects: Map&lt;Location, Thing list&gt;) =
      let objs = objects.[player.Location]
      let attempt = objs |&gt; List.partition (fun o -&gt; o.Name = thing)
      match attempt with
      | [], _ -&gt; "You cannot get that.", player, objs
      | thing :: _, things -&gt;
          let player' = { player with Objects = thing :: player.Objects }
          let msg = sprintf "You are now carrying %s %s" thing.Article thing.Name
          msg, player', things
  
  let player = { Location = Room; Objects = [] }   
  
  let objects =
      [Room, [{ Name = "whiskey"; Article = "some" }; { Name = "bucket"; Article = "a" }];
      Garden, [{ Name = "chain"; Article = "a length of" }]]
      |&gt; Map.ofList
  
  let msg, p', o' = pickUp player "bucket" objects
  // etc.
  </code></pre>
  
  <p>How can I factor out the explicit state to make it prettier? (Assume I have access to a State monad type if it helps; I know there is sample code for it in F# out there.)</p>