pera

pera

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? :slightly_smiling_face:

For those who are not familiar with this project, here is a great introduction to it by its author:

Showing Posts 1 to 10

lpil

lpil

Creator of Gleam

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 :slight_smile:

hassan

hassan

super useful when for example you are working with complex data structures

Do you have an example of such a data structure and how this would apply?

Arpple

Arpple

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

al2o3cr

al2o3cr

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.

OvermindDL1

OvermindDL1

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.

Yeah this is the big big thing.

pera

pera OP

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 :slight_smile:

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 :sweat_smile:

But if you are OK with some (simple) Haskell you may like Patrick Thomson’s introductory series on Recursion Schemes.

Cheers!

doma_dev

doma_dev

We are currently experimenting with replacing standard stack with Witchcraft.

In our experience, it reduces boilerplate so much and allows to get straight to the point, as well as significantly increasing maintainability of the code.

Of course, we’re looking forward and intend to continue to contribute to Gleam ecosystem and we’re keeping a keen eye on purerl, but in the meantime and on “lean startup” budgets, we think that Witchcraft is a good foundation that gives us the best of both worlds.

P.S.
We found that as far as typeclasses are concerned, witchcraft strongly suggesting on putting proptests close to typeclass definitions makes us write way less nonsense than we would in Haskell.

And we wrote a lot of nonsense in Haskell over the course of our careers :slight_smile:

Sebb

Sebb

Eager to see a real world example.

I’d personally never (or only with very obvious benefits) use it my code. It’s hard enough to find Elixir-devs like it is, if you add that to your code It’ll become impossible (… or maybe I’m wrong and you attract all the geniuses…?)

doma_dev

doma_dev

real world example

Here are three examples from the devops engineering project we’re currently working on:

Any time you write Enum.map followed by Enum.into, you should instead use map from Witchcraft.

Sometimes, you need to pipe into second argument of a binary function, having flip is convenient.

Sometimes, you work with a macro that wants to have a single do-block. Having fix at hand is convenient for easy implementaiton of anonymous recursion.


only with very obvious benefits

The first real world example is enough of a reason, according to you, to use Witchcraft! :wink:


Regarding hiring: I feel like we’re in the market for different kind of Elixir developers than most, but I wouldn’t label them as “geniuses”. It’s just a matter of taste in engineering and a matter of skill in different methodologies of building systems. Most of us are coming to Elixir from Haskell, which, arguably, harbours less “genius” people, as instead of working out everything oneself, Haskellers heavily rely on their compiler to aid them in figuring out what does make sense and what doesn’t. But I think it’s really not on-topic here. Witchcraft is practical and should be used by everyone in one capacity or another.

Sebb

Sebb

map, flip and fix are handy, but I can live with into and then.

What I find intimidating and interesting about witchcraft is more this stuff:

Semigroupoid  Semigroup  Setoid   Foldable   Functor -----------┐
     ↓           ↓         ↓         ↓      ↙   ↓   ↘           |
  Category     Monoid     Ord    Traversable  Apply  Bifunctor  |
     ↓                                       ↙    ↘             ↓
   Arrow                            Applicative   Chain       Extend
                                             ↘    ↙             ↓
                                              Monad           Comonad

Where Next? Top

Trending in Discussions Top

cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
achempion
I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and sp...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews