- 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?)
- TODO: Does this mean no more
- Unified def syntax (no more
fn
vsdef
) - 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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Type checking and inference in 100 lines of Rust | |
//! ---------------------------------- | |
//! (if you don't count comments) | |
#![allow(dead_code)] | |
/// The ID of a type variable. | |
#[derive(Copy, Clone, Debug, PartialEq)] | |
struct TyVar(usize); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Term = &'static str; | |
#[derive(Clone, Debug)] | |
enum TyInfo { | |
Unknown, | |
Ref(TyVar), | |
Term(Term), | |
Bool, | |
Int, | |
Func(TyVar, TyVar), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)>), | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Clone, Debug)] | |
pub enum Plural { | |
All, | |
Specific, | |
Exactly(i64), | |
} | |
#[derive(Clone, Debug)] | |
pub enum Logical { | |
And, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { ... } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use graphael::*; | |
use winit::{ | |
event::Event, | |
window::WindowBuilder, | |
event_loop::{ControlFlow, EventLoop}, | |
}; | |
#[derive(Copy, Clone, Pod, Zeroable)] | |
#[repr(C)] | |
pub struct Globals { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
} |
NewerOlder