💾 Archived View for tozip.chickenkiller.com › 2022-06-20-catty-hare.gmi captured on 2023-04-19 at 22:51:52. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-07-16)

-=-=-=-=-=-=-

Copying stdin to stdout using Hare

Created 2022-06-20

I have been kicking the tyres of the Hare programming language recently. I find that a useful program to create when exploring new programming languages is to echo stdin to stdout. Here is one way you can do it in Hare:

use fmt;
use io;
use os;

export fn main() void = {
        let b =  [0u8];
        for (true) {
                // using "match" seems idomatic for Hare, but I don't think we really need it here
                if(io::read(os::stdin, b) is io::EOF) { break; };
                io::write(os::stdout, b)!;
        };
};

Here is a Makefile:

BINS = catty

all : catty

catty : catty.ha
        hare build -o $@ $^

clean :
        rm -f $(BINS)

The Hare programming language