Examples

This is a series of examples showing capabilities in action using ocaps.

Note

If you are not familiar with capabilities, please read through the guide for a more in-depth explanation.

Imports

All the examples given rely on the following imports:

import ocaps._
import ocaps.macros._

Construction Patterns

This section shows creation of capabilities and direct use.

Structural Patterns

This section shows structural patterns that do not change behavior.

Behavioral Patterns

This section shows patterns that change the behavior of capabilities, typically adding side effects or blocking execution completely.

Operational Patterns

This section shows capabilities used together to either unlock new functionality through amplification or represent higher level functionality through abstraction.

Authorization Patterns

This section shows capabilities in the context of authorization and delegation.

Confinement Patterns

This section shows capabilities being rendered inaccessible or made accessible through a membrane.

Responsibility Tracking

This section shows how to track identity and responsibility through capabilities.

The source code for this page can be found here.