Skip to content

Instantly share code, notes, and snippets.

View fogti's full-sized avatar

Ellen Emilia Anna Zscheile fogti

View GitHub Profile
@fogti
fogti / basic_block.zig
Created January 23, 2022 08:12
LC1C partially (without peephole optimizer) ported to Zig (original = https://github.com/zseri/lc1c)
const std = @import("std");
const Allocator = std.mem.Allocator;
pub fn BasicBlock(comptime Stmt: type, comptime Cond: type) type {
return struct {
// entry points
labels: std.ArrayList([]const u8),
entp_cnt: usize,
// exit points
@fogti
fogti / yanais-00.yns
Created August 17, 2023 22:51
possible Yanais introductory example (proglang planning phase)
(*
what language features do we want?
* free tagged unions
* dependent types
*)
mod Example {
pub tag True;
@fogti
fogti / Ast.zig
Created August 24, 2023 18:27
trying to get familiar with ASTs in Zig again...
//! Abstract Syntax Tree for yanais source code
const std = @import("std");
const assert = std.debug.assert;
const testing = std.testing;
const Allocator = std.mem.Allocator;
nodes: NodeList.Slice,
extra_data: []const u8,
@fogti
fogti / hiprofun.idr
Created September 15, 2023 09:21
Dependent Profunctor
interface HiProfunctor (0 p : (0 xt : Type) -> (xt -> Type) -> Type) where
dimap : (a, b : Type) -> (c : b -> Type) -> (d : (a -> Type))
-> (ab : (a -> b)) -> ((y : a) -> c (ab y) -> d y)
-> p b c -> p a d
data DepFun : (0 xt : Type) -> (xt -> Type) -> Type where
DF : (0 xt : Type) -> (yt : xt -> Type) -> ((x : xt) -> yt x) -> DepFun xt yt
HiProfunctor DepFun where
dimap a b c d ab acd (DF _ _ bc) = DF a d (\av : a => acd av (bc (ab av)))
@fogti
fogti / README.md
Last active July 17, 2024 11:49
polymake
@fogti
fogti / fefe-only-links.py
Created October 14, 2023 18:38
fefe, but only the links (without the comments)
const ostag = @import("builtin").os.tag;
const std = @import("std");
const testing = std.testing;
const Allocator = std.mem.Allocator;
fn findExt(name: []const u8) usize {
var start: usize = 0;
// search for last segment after "."
while (std.mem.indexOfPos(u8, name, start, ".")) |delim_start| {
start = delim_start + 1;