You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/2025-01-09-v0.3.0-release.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ CGP introduces a novel approach to error handling that differs significantly fro
30
30
31
31
CGP provides a robust mechanism for dependency injection using [impl-side dependencies](https://patterns.contextgeneric.dev/impl-side-dependencies.html). However, since these dependencies are expressed through traits and constraints, we need to define _accessor traits_ to retrieve field values from a generic context.
32
32
33
-
In the [new chapter](https://patterns.contextgeneric.dev/field-accessors.html), we explore different approaches for defining, using, and implementing accessor traits in CGP. This chapter explains how the `#[derive(HasField)]` macro operates and dives into the internal workings of `HasField` and `symbol!`. It also introduces the` #[cgp_auto_getter]` and `#[cgp_getter]` macros, which automatically generate accessor provider implementations that work with `HasField`.
33
+
In the [new chapter](https://patterns.contextgeneric.dev/field-accessors.html), we explore different approaches for defining, using, and implementing accessor traits in CGP. This chapter explains how the `#[derive(HasField)]` macro operates and dives into the internal workings of `HasField` and `Symbol!`. It also introduces the` #[cgp_auto_getter]` and `#[cgp_getter]` macros, which automatically generate accessor provider implementations that work with `HasField`.
Copy file name to clipboardExpand all lines: content/blog/2025-06-14-hypershell-release.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,10 +105,10 @@ For instance, the previous "hello world" program can be rewritten as follows:
105
105
```rust
106
106
pubtypeProgram=Pipe<Product![
107
107
SimpleExec<
108
-
StaticArg<symbol!("echo")>,
108
+
StaticArg<Symbol!("echo")>,
109
109
WithStaticArgs<Product![
110
-
symbol!("hello"),
111
-
symbol!("world!"),
110
+
Symbol!("hello"),
111
+
Symbol!("world!"),
112
112
]>,
113
113
>,
114
114
StreamToStdout,
@@ -119,9 +119,9 @@ Compared to the "prettified" version, the raw Hypershell syntax is slightly more
119
119
120
120
You can also see that the `WithStaticArgs[...]` syntax **desugars** to `WithStaticArgs<Product![...]>.` With `hypershell!`, syntax that accepts a variable number of arguments can use the `[]` shorthand to wrap the inner arguments within `Product!`. This results in cleaner, more concise syntax, making Hypershell programs more readable.
121
121
122
-
Finally, you might notice that all occurrences of strings are wrapped inside the **`symbol!`** macro from CGP. This is because Hypershell programs are types, but string literals are value-level expressions. The `symbol!` macro allows you to turn string literals into _types_, enabling their use within type expressions.
122
+
Finally, you might notice that all occurrences of strings are wrapped inside the **`Symbol!`** macro from CGP. This is because Hypershell programs are types, but string literals are value-level expressions. The `Symbol!` macro allows you to turn string literals into _types_, enabling their use within type expressions.
123
123
124
-
Behind the scenes, `symbol!` functions similarly to **const-generics** in Rust. However, since Rust doesn't yet support using `String` or `&str` as const-generic arguments, the macro desugars the string literal into a type-level list of `char`, which *can* be used with const-generics.
124
+
Behind the scenes, `Symbol!` functions similarly to **const-generics** in Rust. However, since Rust doesn't yet support using `String` or `&str` as const-generic arguments, the macro desugars the string literal into a type-level list of `char`, which *can* be used with const-generics.
125
125
126
126
With these three syntax transformations, we can now better understand how the `hypershell!` macro works. In Hypershell's DSL architecture, the `hypershell!` macro provides the _surface syntax_ of the DSL, which is then desugared into Rust types that serve as the _abstract syntax_.
127
127
@@ -746,7 +746,7 @@ pub trait HasCommandArgType {
746
746
747
747
The `CommandArgExtractor` component provides an `extract_command_arg` method to extract a command-line argument from an `Arg` code type. This method returns an abstract `CommandArg` type, which can be instantiated with concrete types like `PathBuf` or `String`.
748
748
749
-
For example, given code like `SimpleExec<StaticArg<symbol!("echo")>, ...>`, the `Arg` type passed to `CanExtractCommandArg` would be `StaticArg<symbol!("echo")>`. This means that for `HandleSimpleExec` to implement `Handler<Context, SimpleExec<StaticArg<symbol!("echo")>, ...>, Input>`, it requires `Context` to implement `CanExtractCommandArg<StaticArg<symbol!("echo")>>`.
749
+
For example, given code like `SimpleExec<StaticArg<Symbol!("echo")>, ...>`, the `Arg` type passed to `CanExtractCommandArg` would be `StaticArg<Symbol!("echo")>`. This means that for `HandleSimpleExec` to implement `Handler<Context, SimpleExec<StaticArg<Symbol!("echo")>, ...>, Input>`, it requires `Context` to implement `CanExtractCommandArg<StaticArg<Symbol!("echo")>>`.
750
750
751
751
Since `extract_command_arg` returns an abstract `CommandArg` type, `HandleSimpleExec` also has an additional constraint: `Context::CommandArg: AsRef<OsStr> + Send`. This implies that the context can instantiate `CommandArg` with any concrete type that implements `AsRef<OsStr> + Send`, such as `PathBuf` or `OsString`.
752
752
@@ -771,25 +771,25 @@ To see this in action, consider the example code:
771
771
772
772
```rust
773
773
SimpleExec<
774
-
StaticArg<symbol!("echo")>,
774
+
StaticArg<Symbol!("echo")>,
775
775
WithStaticArgs<Product![
776
-
symbol!("hello"),
777
-
symbol!("world!"),
776
+
Symbol!("hello"),
777
+
Symbol!("world!"),
778
778
]>,
779
779
>
780
780
```
781
781
782
-
The `Args` type given to `HandleSimpleExec` would be `WithStaticArgs<Product![symbol!("hello"), symbol!("world!")]>`. This means the following constraint needs to be satisfied:
782
+
The `Args` type given to `HandleSimpleExec` would be `WithStaticArgs<Product![Symbol!("hello"), Symbol!("world!")]>`. This means the following constraint needs to be satisfied:
To keep our focus on the core implementation of `HandleSimpleExec`, we'll omit the detailed workings of argument updates. At a high level, the main idea is to perform a **type-level iteration** on the list passed to `WithStaticArgs`. So, the implementation would be broken down into two smaller constraints:
Once we reach each individual argument, we then use `CanExtractCommandArg` to extract the argument and subsequently call [`Command::arg`](https://docs.rs/tokio/latest/tokio/process/struct.Command.html#method.arg) to add it to the `Command`.
Copy file name to clipboardExpand all lines: content/blog/2025-06-14-v0.4.1-release.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,4 +170,4 @@ This release also includes several other minor improvements and fixes:
170
170
171
171
---
172
172
173
-
We hope you enjoy the new features and improvements in this release. As always, we welcome feedback and contributions from the community. Check out the project on [GitHub](https://github.com/contextgeneric/cgp/) and the full [changelog](https://github.com/contextgeneric/cgp/blob/main/CHANGELOG.md) for more details.
173
+
We hope you enjoy the new features and improvements in this release. As always, we welcome feedback and contributions from the community. Check out the project on [GitHub](https://github.com/contextgeneric/cgp/) and the full [changelog](https://github.com/contextgeneric/cgp/blob/main/CHANGELOG.md) for more details.
0 commit comments