0
votes

I've been spending time lately to grasp FP concepts and especially the free monad. I think I understand the idea behind free monads quite well, but a question arose.

I've been using Doobie for a bit which is built on top of free monads. For me, it would make sense to have different algebras combined (with coproducts), including doobie. When testing algebras, people usually create a test interpreter. But for existing libraries like Doobie (which algebra is kinda large), do I need to create a test interpreter on my own? For me, at this point using the free monad gives a lot of boilerplate code. Also, if the approach is wrong, I would love to get some feedback.

A more frequently asked question maybe, but what are the use cases you tend to use them for? Do you use them for structuring nearly every FP application or are there only particular use cases where the free monad shines.

Thanks in advance!

1
Have a look at frees.io/docsDaenyth

1 Answers

0
votes

Doobie is great, it is very complex under the surface, but it is simple to use. You do not need to touch the free monad to use Doobie.

I do not really see any reason to touch the free monad unless you are contributing to the Doobie project.

For unit test you can use H2 there is also a special Doobie Spec package.

https://tpolecat.github.io/doobie-0.2.1/11-Unit-Testing.html

Regarding other uses of the free monad: The free monad is a very sophisticated tool for solving hard problems. People that are new to functional programming want to use all the shiny new toys. This causes a lot of over engineering. :D

The only good use of the free monad I know of is Doobie.