title: How can I move something from one database to another using Haskell?
body: <p>I'm fairly new to Haskell; I've read countless tutorials and other resources on it, but whenever I decide to try to write programs doing anything remotely useful, I usually don't even know where to begin. I was recently listening to a podcast where Gabriel Gonzalez talked about how the best way to stay motivated is to actually use it for projects and just get writing, so I really want to use it for a task I have at hand.</p>
  
  <p>So, I have a Mongo database which is constantly getting updated with items being scraped regularly, and an Elasticsearch database. The former will frequently get updated with items I have already scraped before, while the latter is populated with unique items. To achieve this I have a script (1000 lines of Node.js) which is constantly running and consuming the items in the Mongo database one by one, doing some checks to see if it's already in the Elasticsearch database, and adding it if it's not; afterwards, it's deleted from Mongo. This script is however a total mess.</p>
  
  <p>I've been wanting to do this in Haskell, since Haskell is great for managing IO in a controlled manner from what I've read and heard, and since I like the idea of keeping pure functions for transforming the data and the parts of the program actually performing IO separate. I also assume a working Haskell solution would be more concise, and easier to reason about when changing things later.</p>
  
  <p>So far I've managed to use the mongoDB package to do CRUD operations in Mongo by following the tutorial, but there are still a lot of things I don't understand about how it works. I find it harder to work with the bloodhound package for doing the same things in Elasticsearch, and I'm completely stumped as to how I would piece things together, especially while ensuring that the relevant items only get deleted from Mongo after having been successfully added to Elasticsearch.</p>
  
  <p>I know this is a very broad question, but if anyone knows anything about this, or simply are able to give me some direction, I would appreciate it. In fact, all help would be very much appreciated.</p>