Skip to content

Commit 001bbc1

Browse files
authored
Merge pull request #10 from contextgeneric/v0.5.0-release
V0.5.0 release blog post
2 parents b8812e6 + ecd84b6 commit 001bbc1

11 files changed

+1018
-218
lines changed

code/Cargo.lock

Lines changed: 82 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/Cargo.toml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,7 @@ name = "abstract-name"
1212
path = "bin/abstract_name.rs"
1313

1414
[dependencies]
15-
cgp = { version = "0.4.0" }
15+
cgp = { version = "0.5.0" }
1616

1717
[patch.crates-io]
18-
# cgp = { git = "https://github.com/contextgeneric/cgp.git" }
19-
# cgp-core = { git = "https://github.com/contextgeneric/cgp.git" }
20-
# cgp-extra = { git = "https://github.com/contextgeneric/cgp.git" }
21-
# cgp-async = { git = "https://github.com/contextgeneric/cgp.git" }
22-
# cgp-async-macro = { git = "https://github.com/contextgeneric/cgp.git" }
23-
# cgp-component = { git = "https://github.com/contextgeneric/cgp.git" }
24-
# cgp-macro = { git = "https://github.com/contextgeneric/cgp.git" }
25-
# cgp-macro-lib = { git = "https://github.com/contextgeneric/cgp.git" }
26-
# cgp-type = { git = "https://github.com/contextgeneric/cgp.git" }
27-
# cgp-field = { git = "https://github.com/contextgeneric/cgp.git" }
28-
# cgp-error = { git = "https://github.com/contextgeneric/cgp.git" }
29-
# cgp-error-extra = { git = "https://github.com/contextgeneric/cgp.git" }
30-
# cgp-error-anyhow = { git = "https://github.com/contextgeneric/cgp.git" }
31-
# cgp-run = { git = "https://github.com/contextgeneric/cgp.git" }
32-
# cgp-runtime = { git = "https://github.com/contextgeneric/cgp.git" }
33-
# cgp-sync = { git = "https://github.com/contextgeneric/cgp.git" }
34-
# cgp-inner = { git = "https://github.com/contextgeneric/cgp.git" }
18+
cgp = { git = "https://github.com/contextgeneric/cgp.git", branch = "v0.5.0-release" }

content/blog/2025-01-09-v0.3.0-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CGP introduces a novel approach to error handling that differs significantly fro
3030

3131
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.
3232

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`.
3434

3535
# `cgp` v0.3.0 Release
3636

content/blog/2025-05-09-v0.4.0-release.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ delegate_components! {
303303
MyContextComponents {
304304
ListenPortGetterComponent:
305305
WithProvider<ChainGetters<Product! [
306-
UseField<symbol!("config")>,
307-
UseField<symbol!("network")>,
308-
UseField<symbol!("listen_port")>,
306+
UseField<Symbol!("config")>,
307+
UseField<Symbol!("network")>,
308+
UseField<Symbol!("listen_port")>,
309309
]>>
310310
}
311311
}
@@ -381,8 +381,8 @@ The derive macro would generate the following `HasField` implementation:
381381
impl HasFields for Person {
382382
type Fields =
383383
Product! [
384-
Field<symbol!("name"), String>,
385-
Field<symbol!("age"), u64>,
384+
Field<Symbol!("name"), String>,
385+
Field<Symbol!("age"), u64>,
386386
];
387387
}
388388
```
@@ -393,8 +393,8 @@ Additionally, [#85](https://github.com/contextgeneric/cgp/pull/85) introduces th
393393

394394
```rust
395395
Product! [
396-
Field<symbol!("name"), String>,
397-
Field<symbol!("age"), u8>,
396+
Field<Symbol!("name"), String>,
397+
Field<Symbol!("age"), u8>,
398398
]
399399
```
400400

content/blog/2025-06-14-hypershell-release.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ For instance, the previous "hello world" program can be rewritten as follows:
105105
```rust
106106
pub type Program = Pipe<Product![
107107
SimpleExec<
108-
StaticArg<symbol!("echo")>,
108+
StaticArg<Symbol!("echo")>,
109109
WithStaticArgs<Product![
110-
symbol!("hello"),
111-
symbol!("world!"),
110+
Symbol!("hello"),
111+
Symbol!("world!"),
112112
]>,
113113
>,
114114
StreamToStdout,
@@ -119,9 +119,9 @@ Compared to the "prettified" version, the raw Hypershell syntax is slightly more
119119

120120
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.
121121

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

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

126126
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_.
127127

@@ -746,7 +746,7 @@ pub trait HasCommandArgType {
746746

747747
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`.
748748

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")>>`.
750750

751751
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`.
752752

@@ -771,25 +771,25 @@ To see this in action, consider the example code:
771771

772772
```rust
773773
SimpleExec<
774-
StaticArg<symbol!("echo")>,
774+
StaticArg<Symbol!("echo")>,
775775
WithStaticArgs<Product![
776-
symbol!("hello"),
777-
symbol!("world!"),
776+
Symbol!("hello"),
777+
Symbol!("world!"),
778778
]>,
779779
>
780780
```
781781

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

784784
```rust
785-
Context: CanUpdateCommand<WithStaticArgs<Product![symbol!("hello"), symbol!("world!")]>>
785+
Context: CanUpdateCommand<WithStaticArgs<Product![Symbol!("hello"), Symbol!("world!")]>>
786786
```
787787

788788
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:
789789

790790
```rust
791-
Context: CanUpdateCommand<StaticArg<symbol!("hello")>>
792-
+ CanUpdateCommand<StaticArg<symbol!("world!")>>
791+
Context: CanUpdateCommand<StaticArg<Symbol!("hello")>>
792+
+ CanUpdateCommand<StaticArg<Symbol!("world!")>>
793793
```
794794

795795
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`.

content/blog/2025-06-14-v0.4.1-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,4 @@ This release also includes several other minor improvements and fixes:
170170

171171
---
172172

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

Comments
 (0)