title: Haskell, MongoDB driver, >>=, and <<=
body: <p>EDIT:  Wanted to get this in real quick before the forum moderator trolls shut this down (they've been retroactively going through my posts which are months old, down voting them, then closing them).  The problem is either the driver or the docs, because the example code has the same issue when I run it.</p>
  
  <p>I'm trying to evaluate Haskell in terms of using it with MongoDB.  I've tried to write my own simple program to do simple things to a database using examples on this driver page <a href="https://github.com/TonyGen/mongoDB-haskell" rel="nofollow">https://github.com/TonyGen/mongoDB-haskell</a> .  I can get as far as opening a connection and even making inserts into a database (I checked the DB, everything makes it inside).  The problem I'm running into is, once I open a connection and do something, I can't get the Haskell program to "come back" to the interpreter, print some value, or do anything else.  This may be the wrong word, but I think the program is essentially "locked."</p>
  
  <p>Not sure, but I believe that I'm not terminating correctly inside the "do" notation, thus I think it's just sitting there.  In looking at the examples on the driver page, I notice that it makes use of operators such as >>= and &lt;&lt;=.  I suspect (not sure) that I need one or both of these operators to terminate from the "do," or somehow finish what I'm doing.</p>
  
  <p>I'd just like some clear examples of an operator or operators I need and how to use them to finish this "do" and get back to the interpreter, possibly with some return value like "finished" or whatever.  The explanation should be in very basic, practical, plain-spoken, matter of fact terms, spoken in an almost unsophisticated or juvenile way.  The explanation should not focus on how it does what it does, why it does what it does, or what goes on inside this operator or operators.  It should just be how to use it to do "such and such."</p>
  
  <p>An example (wrong in what it instructs, correct in how the instruction should look):</p>
  
  <blockquote>
    <p>"See that thing that looks like a backwards arrow (<code>&lt;&lt;=</code>)?  That's called the
        'backwards arrow operator.'  Any time we want to stop execution from a do,
        and shoot information back from the monadic world to the world of pure Haskell,
        we use that operator to do it.  How it works is, you stick the information you
        want to shoot back on the right hand side.  On the left, you 
        stick...."</p>
  </blockquote>
  
  <p>I don't want any explanation of what a monad is, how to use a monad, what goes on inside a monad, how a monad works, etc.  I've consulted the literature numerous times. </p>
  
  <p>I also don't want explanations of what these operators such as >>= or &lt;&lt;= are, or how they work, what they are doing, etc.  I want explanations of HOW TO USE THEM (if needed), just not the theoretical (or other) stuff.</p>
  
  <p>I've already scanned this website and other documentation but couldn't find what I was looking for in the format I wanted it (described above).</p>
  
  <p>EXAMPLE CODE</p>
  
  <pre><code>{-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-}
  
  import Database.MongoDB
  import Control.Monad.Trans (liftIO)
  
  main = do
      pipe &lt;- runIOE $ connect (host "127.0.0.1")
      e &lt;- access pipe master "test" run
      close pipe
      print e
  
  run = do
      test_insert
      -- missing something here?  tried return "finished" and other things
  
  test_insert = insertMany "blah" [ stuff... ]
  </code></pre>