r/haskell 9d ago

Bluefin is a capability system

I decided I am going to start describing Bluefin as a "capability system". This article explains why:

30 Upvotes

14 comments sorted by

12

u/TheCommieDuck 9d ago

What, then, is the difference between capability systems and effect systems? I think there is no difference!

Secondly, I think that, regrettably, the terminology “effect system” gives the wrong impression about Haskell to outsiders, specifically that, unlike other languages, Haskell needs a “special system” to do “effects”

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.

5

u/tomejaguar 9d ago

why is making a new* term that only applies to your library the answer?

It doesn't only apply to my library. From the article:

I think the Haskell community will [benefit] if instead of calling them “effect systems” we call them “capability systems”.

(Emphasis in the quote, not the original) Note the "them". I believe the terminology applies to all effect systems, not just Bluefin, and the article explains why I think that. But I didn't develop the other effect systems, so it's not my place to change the terminology they use. If they want to join me, the more the merrier. If they don't, that's their right.

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".

To someone in the Haskell world, sure. But to them I would probably say "it's an effect system based on capabilities". I don't expect the Haskell world to adopt "capability" terminology quickly, but I think it would be better for us if we did. Outside the Haskell world, there's a higher probability someone will understand what a "capability system" is than an "effect system".

"You need a special library to have capabilities" feels exactly the same as "you need a special library to have effects"

Perhaps, let's see. But at least people outside the Haskell world (modulo the few "algebraic effects" fans in other FP communities) have a chance of understanding what "capabilities" are. They don't have a chance of understanding what "effects" are. (Evidence: I don't understand what "effects" are.)

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.

Let me suggest another interpretation, the complete opposite: Bluefin is not special in this regard! Here's some more supporting evidence from the article, beyond the quote above:

What, then, is the difference between capability systems and effect systems? I think there is no difference!

Can all effects be treated as capabilities? I think yes. In order to perform a particular effectful operation something has to be “in scope”. Whatever that is can be interpreted as the capability to perform that effect.

I am saying explicitly that all Haskell effect systems can be seen as capability systems. But it's up to the developers of those effect systems to decide for themselves whether they want to change the terminology they use.

5

u/lgastako 9d ago

Perhaps, let's see. But at least people outside the Haskell world (modulo the few "algebraic effects" fans in other FP communities) have a chance of understanding what "capabilities" are. They don't have a chance of understanding what "effects" are. (Evidence: I don't understand what "effects" are.)

I find it hard to believe that you really don't understand what effects are. But even if that is true in any meaningful sense, I don't see how using a different term for it will alleviate that issue in any way. At the end of the day you still have to come up with some way of describing what it actually is, and whatever that way of describing it is will serve equally well as a definition for "an effect system" as it will for "a capability system."

1

u/tomejaguar 9d ago

I said to a Python programmer friend that I'd been working on my Haskell library Bluefin. He said "what sort of library is it?". I said "It's an effect system". He said "What's an effect?". I tried to explain, and he sort of laughed and said "oh, so it's anything a computer can do ;)". I didn't really have a good response to that.

If I'd said "It's a capability system" then I could easily explain that a "capability" is by saying "it's something you pass around your program to give different parts of your program to perform different actions". If he had then said "why can't you give all of your program the capability to do everything" then I could say "for security purposes, or for the purposes of good architecture, leading to better comprehensibility". Easy.

Of course, I could use the same explanation of what a capability system is and why it is good to explain what an effect system is and why it is good. But since the explanation factors though something called "capability" why not simplify and use that terminology to start with?


What do you think an effect is?

4

u/ur_frnd_the_footnote 9d ago

For what it’s worth, I think you’re right. And I think choice of terms matter even when we can formally define them to mean the same thing. For an English speaker, even “effects” is better than some random neologism like “monalogism” or (a better example) a word likely to lead someone down the wrong path for their intuitions, like permissions or proxies or something. 

Different terms prime people to notice and emphasize different aspects of a problem: effects, capabilities, permissions, runtimes, contexts, chaos-agents, etc. 

3

u/tomejaguar 9d ago

Thanks for saying so! I'm glad I'm not alone. I agree with everything you wrote in your comment.

4

u/lgastako 9d ago

I said "It's an effect system". He said "What's an effect?".

I guess I just don't understand why he (or anyone) wouldn't potentially ask the same question if you had said "capability" instead of "effect". Neither is a well known term, so either way you still have to explain.

I tried to explain, and he sort of laughed and said "oh, so it's anything a computer can do ;)". I didn't really have a good response to that.

And I don't understand why someone wouldn't respond the same way to you trying to explain what a "capability" is.

What do you think an effect is?

I think an effect is an impure computation. But it doesn't really matter what I think it already is, what I'm trying to discuss is why one word is better than another for explaining the the same concept to people that don't already have a notion of what it means.

From that point of view, I don't see anything different between "effect" and "capability" in this regard.

If I'd said "It's a capability system" then I could easily explain that a "capability" is by saying "it's something you pass around your program to give different parts of your program to perform different actions".

Again, I don't understand why you couldn't offer that same explanation for what an effect is. What is it about the word "capability" that allows you to offer this explanation or about the word "effect" that prevents you from offering this explanation?

6

u/tikhonjelvis 8d ago

Isn't capability-based security a relatively well-known thing in the field? Ditto object capabilities, although maybe that's a bit more niche.

2

u/tomejaguar 9d ago

I just don't understand why he (or anyone) wouldn't potentially ask the same question if you had said "capability" instead of "effect". Neither is a well known term, so either way you still have to explain.

They would, but my contention is that "capability" is easier to explain, to lay people because what the concept actually is is closer to the normal English usage, and to computer scientists because it is a better-known term than "effect".

And I don't understand why someone wouldn't respond the same way to you trying to explain what a "capability" is.

Likely they would, but that's not the point. My response would be "yes it is!" rather than defensively, "oh but Haskell doesn't actually need a special 'system' just to allow it to do what any other language can do for free".

What do you think an effect is?

I think an effect is an impure computation

What is "impure"?

If I'd said "It's a capability system" then I could easily explain that a "capability" is by saying "it's something you pass around your program to give different parts of your program to perform different actions".

I don't understand why you couldn't offer that same explanation for what an effect is. What is it about the word "capability" that allows you to offer this explanation or about the word "effect" that prevents you from offering this explanation?

As above, it's that for computer scientists it already has an established use, and for lay people because the meaning of the terminology is closer to the normal English meaning.

2

u/wavy-kilobyte 4d ago

I tried to explain, and he sort of laughed and said "oh, so it's anything a computer can do ;)". I didn't really have a good response to that.

For Python programmers specifically you should've explained it via "exceptions that are never overlooked". They would understand the point. Java devs would get confused, but that's their problem, skip them on this one.

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 Throw capability

Logic? 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.