Our great sponsors
-
purescript-free
Free monads, Cofree comonads, Yoneda and Coyoneda functors, and the Trampoline monad.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
There are many great articles on why Free Monads are the bee's knees, notably by Gabriel Gonzalez here and here. At the end of this article, I'll give a couple of reasons that I like to use them. But here, I'd like to talk about why they are super annoying - you have to write all those functions! And even worse, you have to do it twice! Once to make the free monad, and once to transform it into the execution monad (ie Aff or IO or Identity or whatever). That's what purescript-freer-free fixes.
Those are the elements of the program, and we mix and match them as we please. The way we transform those into a free monad is using purescript-free. In the "bad old days" (meaning a couple days ago, before purescript-freer-free was released) we'd use a function from purescript-free called liftF to turn the ADT above into a monad.
So I find that free monads allow for better testability and easier swapping of implementations in certain situations. That said, we also have services at Meeshkan that are so tightly coupled to the Aff monad that making a free monad just takes too much time, so we just roll with Aff and write a good end-to-end test.
purescript-run: Federate free monads together into an uber-monad using the Variant pattern.
'purescript-freet`: Make your free monad part of a monadic stack.