Hypershell: A Type-Level DSL for Shell-Scripting in Rust powered by Context-Generic Programming

26 points by soareschen


ThinkChaos

I think this focuses a lot on the how, but what I was more interested in as someone new to CGP is the why. I read most of the post and do not feel like I understand why I’d want CGP or Hypershell.

For instance, the native HTTP streaming example doesn’t seem better to me than just writing it out with async Rust:

async fn main() {
    let body = reqwest::get("https://www.rust-lang.org")
        .await
        .expect("HTTP get")
        .bytes_stream();

    let hash = hash_stream(body).await.expect("HTTP body sha256");

    println!("{hash}");
}

async fn hash_stream<E: Error>(
    bytes: impl futures::Stream<Item = Result<Bytes, E>>,
) -> Result<u64, E> {
    todo!()
}

(full code, doesn’t compile on the playground because of a missing reqwest feature, but works locally)

What are the concrete benefits you see for CGP compared to code like this?
I think having the docs first show the limitations in the normal code, and then how CGP solves them would make the value proposition clear. It could be more involved code than the specific example I chose if the issues only arrise in larger programs.

Also, the post is very verbose. When you’re showing code I don’t think there’s value in explaining every single detail. I’m personally more interested in the new concepts the example introduces, and if I want the nitty gritty I’ll dig into the crate’s docs, or even build the example locally.