Skip to content

Instantly share code, notes, and snippets.

View zesterer's full-sized avatar

Joshua Barretto zesterer

View GitHub Profile
@zesterer
zesterer / tao2-wishlist.md
Last active January 23, 2024 22:21
Wishlist for Tao 2

Wishlist for Tao 2

Syntax

  • Indentation sensitivity (so trailing pattern branches don't require \)
  • [ ... ] as kind parameter syntax, to reduce visual ambiguity (i.e: Result A E -> Result[A, E])
    • TODO: Does this mean no more [T] list type syntax? (maybe it meants that already if having values as kinds?)
  • Unified def syntax (no more fn vs def)
  • Unified effect handler and pattern matching syntax (handling errors with effects should be as easy as with sum types)
  • Figure out intuitive, terse, and consistent do notation (or block syntax)
@zesterer
zesterer / unification-with-hrts.rs
Last active July 1, 2023 00:52
Type inference via unification with support for higher-ranked types
type Term = &'static str;
#[derive(Clone, Debug)]
enum TyInfo {
Unknown,
Ref(TyVar),
Term(Term),
Bool,
Int,
Func(TyVar, TyVar),
@zesterer
zesterer / nested_spans.rs
Created June 27, 2023 23:57
Chumsky's nested.rs example, but with spans included
use chumsky::{prelude::*, input::SpannedInput};
// This token is a tree: it contains within it a sub-tree of tokens
#[derive(PartialEq, Debug)]
enum Token {
Num(i64),
Add,
Mul,
Parens(Vec<(Token, SimpleSpan)>),
}
#include <stdio.h>
int bar(unsigned int x) {
for (int i = x - 1; i >= 2; i--)
for (int s = x; s >= 0; s -= i)
if (s == 0)
return 0;
return 1;
}
#[derive(Clone, Debug)]
pub enum Plural {
All,
Specific,
Exactly(i64),
}
#[derive(Clone, Debug)]
pub enum Logical {
And,
@zesterer
zesterer / rtsim2.rs
Created January 25, 2022 17:04
Veloren rtsim2 data model ideas
// Top-level rtsim state. The contents of this struct are entirely sufficient to describe the state of the world.
struct RtState {
temporal: &mut Temporal,
agents: &mut Agents,
}
// Contains tick-by-tick information such as decision tree state, short-term planning, aggro, current activity, etc.
// Agents can be both single characters and groups of characters (see `Groups`).
struct Agents { ... }
use graphael::*;
use winit::{
event::Event,
window::WindowBuilder,
event_loop::{ControlFlow, EventLoop},
};
#[derive(Copy, Clone, Pod, Zeroable)]
#[repr(C)]
pub struct Globals {
use super::*;
use std::collections::VecDeque;
pub type InferMeta = (Span, TyVar);
pub type InferNode<T> = Node<T, InferMeta>;
#[derive(Clone, Debug)]
pub enum TyInfo {
Ref(TyVar),
Error,
@zesterer
zesterer / priced_economy.rs
Created July 20, 2021 21:36
Economy with labour value but prices instead of derived consumption value
use std::collections::BTreeMap as HashMap;//HashMap;
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
enum Good {
Log, // Units: Kg
Wood, // Units Kg
Meat, // Units: Kg
Food,
}
@zesterer
zesterer / materialist_economy.rs
Last active August 8, 2021 21:29
A simulation of a materialist economy: centrally-planned workforce allocation and propagation of labour value and consumption value across the supply chain, leading to pareto efficiency
use std::collections::BTreeMap as HashMap;//HashMap;
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
enum Good {
Log, // Units: Kg
Wood, // Units Kg
Fish, // Units: Kg
Food,
}