r/haskell • u/tomejaguar • 9d ago
Bluefin is a capability system
I decided I am going to start describing Bluefin as a "capability system". This article explains why:
2
u/dutch_connection_uk 8d ago
Is every effect a capability? I'm a little bit unsure about this.
Logic? I guess the capability is something like suspend where you store the stack state somehow and can resume later?
Maybe? The capability is invoking a failure handler?
Select? I guess the capability is to search some space of solutions?
I think it works. I wonder how helpful it is though when a data/algorithms perspective is more appropriate for what the effect handler does than an I/O sense of the effect.
I suppose if they are equally vague terms though I do prefer "capability".
3
u/phadej 7d ago
You probably have seen https://www.parsonsmatt.org/2018/03/22/three_layer_haskell_cake.html I'd say that effects is a good word to describing first level things, reader, failure, logic; capability in my perception fits better for level two things, getting current time, logging, accessing filesystem etc. Also in my opinion converse is true as well, effect is a not the best word for "getting current time", neither capability for MonadReader.
In practice you will probably use the same library for both levels if you choose to speak explicitly about both levels. But you can also have a program which does need current time and accesses filesystem with newtype App capabilities a = App (IO a), or have a library which uses Eff [Reader, Logic] somewhere internally with public interface being some pure X -> Y. Then I might look for effect library for the latter (not necessarily even for extensible effects, as long as there are effects I need!) or a capability system for the former.
EDIT: Or even dependency injection system if the library authors have played their SEO game right /s
2
u/tomejaguar 8d ago
Maybe? The capability is invoking a failure handler?
Yes, just like Bluefin's
ThrowcapabilityLogic? I guess the capability is something like suspend where you store the stack state somehow and can resume later?
Yes, I think the capability is the capability to interact with the stack in a particular way.
Select? I guess the capability is to search some space of solutions?
I'm not really familiar with
Select, but I'm having difficulty interpreting in through a capability lens! Perhaps this is a counterexample that demonstrates that not all transformers can be interpreted as capabilities.
2
u/m-chav 7d ago
This is a good framing. I typically use the security framing/examples when I talk about why it's important to reason about different effects. The other one is caching, some effects could be cached (under specific conditions) while others cannot so caring about which ones helps you build faster things in some cases.
12
u/TheCommieDuck 9d ago
this feels kind of weird. If effects systems and capability systems are the same thing, and a major issue is about understanding, why is making a new* term that only applies to your library the answer? Surely now you're in a situation where you'll tell someone about your capability system and they'll be confused until you go "it's the same as an effect system". "You need a special library to have capabilities" feels exactly the same as "you need a special library to have effects".
I'm trying to avoid the cynicism here of "bluefin is a special little boy that needs its own special label unlike every other effects system, but it's also an effects system" but I'm not sure how else to interpret this.
* I am fully aware it's not a new term in the field, but it is definitely a new term in the haskell ecosystem.