I am curious because Witchcraft (and related projects like Algae) can be super useful when for example you are working with complex data structures, yet I almost never see people mentioning it in this forum which makes me wonder, why not?
For those who are not familiar with this project, here is a great introduction to it by its author:
Witchcraft is a very cool library but without a static type system I personally don’t enjoy these design patterns as much as I do in languages like Haskell. I’d love to see this alongside a statically typed Elixir
if you not composing multiple function
most of the time just pattern matching is easier to write and understand
also agree with @lpil that without static type, these structure will be more difficult to understand at first glance
Seconding @hassan’s query: are there examples of this?
The examples in the documentation mostly use numbers, which are simple to use in doctests and automatically satisfy a bunch of properties - but that obscures why a user would want to distinguish between (say) a semigroup and a monoid (since numbers always have zero).
IMO the library would get more attention if it was clearer what problems it makes easier to solve - right now, it mostly seems like using Witchcraft is a way to make Elixir look more like Haskell.
At times I do, both in using and mentioning it, lol.
I don’t really push it out hard because it’s not what most people here are familiar with, Elixir is functional’ish, but it doesn’t really follow the modern functional styles, so it doesn’t fit with ‘other’ things very cleanly.
Apologies for the delayed response, it was an intense week…
Yeah, I mean I agree that having a type checker is helpful, but I found some joy in using these sort of linguistic tools in a language that’s not (a) Haskell
When one is working for instance with recursive data types in languages where immutability is the norm (like in most functional programming languages) many ideas from category theory come very useful as they let you create sound generalizations on how to process data which can be independent from their types and also easy to compose. I would love to write an article on “categorical elixir” full of real world examples but right now I barely have the time to type this post, and besides, I would need to find a very patient reviewer as I’m likely not the right person for such task
But if you are OK with some (simple) Haskell you may like Patrick Thomson’s introductory series on Recursion Schemes.