Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dok8tavo/cogito
Cogito is a zig module that provides comptime only types for high-level metaprogramming.
https://github.com/dok8tavo/cogito
metapr module types zig
Last synced: about 1 month ago
JSON representation
Cogito is a zig module that provides comptime only types for high-level metaprogramming.
- Host: GitHub
- URL: https://github.com/dok8tavo/cogito
- Owner: Dok8tavo
- License: mit
- Created: 2024-12-05T20:36:21.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-27T21:51:16.000Z (about 2 months ago)
- Last Synced: 2024-12-27T22:27:07.583Z (about 2 months ago)
- Topics: metapr, module, types, zig
- Language: Zig
- Homepage:
- Size: 156 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cogito
Cogito is a zig module that offers compile-time only types for high-level metaprogramming.
Since zig's `comptime` can compute types as it goes and allocate memory at will, it should be able
to use the same kind of abstractions as dynamically-typed languages. Cogito implement the
following types:- `List`,
- `Dict`,
- `String`,
- `StringSet`,
- `StructGen`,## Usage
1. Fetch the package by running `zig fetch git+https://github.com/Dok8tavo/cogito --save=cogito`
in the folder containing `build.zig.zon`.2. Get cogito in your `build.zig` script:
```zig
pub fn build(b: *std.Build) !void {
...
const cogito = b.dependency(
// this must be the name you used in the `--save=` option
"cogito", .{
.target = ...,
.optimize = ...,
}).module(
// this one must be "cogito", it's the name of the module from inside
// the package
"cogito"
);
...
}
```3. Add the import for your module/executable/library/test:
```zig
pub fn build(b: *std.Build) !void {
...
const cogito = ...;my_executable_library_or_test.root_module.addImport(
// this can be whatever you want, it'll affect your `@import` calls
"cogito",
cogito,
);my_module.addImport(
// same
"cogito",
cogito,
);
...
}
```4. Import the module in your source code:
```zig
const cogito = @import(
// this is the name you used in the `addImport` function in your
// `build.zig` script.
"cogito"
);
```