For the past 9 months or so I have been studying and tackling Haskell seriously. My previous boss recommended me to have a look into Haskell if I wished to better understand the meaning of pure functional programming. However, things did not go well at the time.
Now, 9 months in and I am just amazed by the things that I have learned. I believe that I have a better understanding of the more difficult concepts such as monoid, functor, traversal, foldable, monad, etc… Actually, I would not say that they are difficult to understand. Once you understand the important laws for each of these “categories”, interacting with them will not be complicated. The difficult part is knowing when creating your own is needed or not in your application. Of course, everything I say here is from the perspective of a fairly new person starting Haskeller. Side note this irrelevant to knowing how to use Haskell but I started reading a bit about category theory and it’s quite amazing, for the curious ones.
I apologize that it took so long to finally introduce the actual topic of this blog but I thought that it was important for me to share some of my experiences first. I recently got this idea to write a library that interacts with Salesforce Rest API using the servant-client library. One of the reason is that I use Salesforce at work, and I thought that maybe if this library goes well it could attract more people to try Haskell..? Another reason is that there so many things that I could do very easily in Haskell and also the expressiveness could allow me to write code that reflects business requirements. Salesforce CRM is great but when it comes to Apex Code…Well, I will leave at that.
The great thing about the Salesforce Rest API is that it gives us access to a lot of important elements of the CRM. For now, I have managed to implement two resources/endpoints the SObject Rows and Query.
The SObject Rows endpoint allows us to retrieve, update and delete a record from Salesforce. Here is what it would look like so far using my library. First and foremost we need an access token from Salesforce to be able to communicate with the API. Somewhere in our project, we would set up our credentials and OAuth request type in a config file. However, for the sake of this example, we will have it all in the same file.
Once we have this setup we can now work with the SObject Row endpoints and retrieve, update and delete data. Let’s see how we can do this with Salesforce’s Account Object.
Finally, we can now define the functions that we would like to use to perform retrieve, update and delete action on an Account.
I will stop this blog here for now. This project is still in very early developing phase. I am still not too sure about the design choices that advance Haskell developers would make. Therefore, I am looking for constructive cristicsm from more advanced Haskellers and also current Salesforce developers about this library.
Github Link: https://github.com/Woody88/Haskforce/tree/new_types
P.S: I just started bloggling so there will be a lot of typos, grammar mistakes and many more… I will work my way through them little by little.