This file contains hidden or 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
// next up: scott encoding https://en.wikipedia.org/wiki/Mogensen%E2%80%93Scott_encoding | |
package main | |
import "fmt" | |
type Church[T any] func(func(T) T) func(T) T | |
func main() { | |
churchTest[int](0, func(x int) int { return x + 1 }) |
This file contains hidden or 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, BTreeSet}; | |
use std::env; | |
use std::io::{self, BufRead}; | |
#[derive(Debug, Default)] | |
struct Node { | |
terminal: bool, | |
children: BTreeMap<char, Node>, | |
} |
This file contains hidden or 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
// Copyright (C) 2022 Tiago Carvalho <[email protected]> | |
// | |
// Permission to use, copy, modify, and/or distribute this software for any | |
// purpose with or without fee is hereby granted. | |
// | |
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
// FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
This file contains hidden or 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
#![feature(iter_array_chunks)] | |
#![feature(hasher_prefixfree_extras)] | |
use std::collections::hash_map::DefaultHasher; | |
use std::hash::{Hash, Hasher}; | |
#[derive(Clone, Debug)] | |
struct Tree<T> { | |
root: Option<Node<T>>, | |
} |
This file contains hidden or 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
import multiprocessing | |
from collections import namedtuple | |
from concurrent.futures import ThreadPoolExecutor | |
Poll = namedtuple('Poll', ['resolved', 'value']) | |
_CURRENT_EXECUTOR = None | |
def enter_runtime(main=None, threads=0): |
This file contains hidden or 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
;; TODO: add backtracking point, to avoid parsing all the way from the beginning! | |
;; | |
;; e.g. | |
;; | |
;; (json-value (new-string-state "[\" \" 123]")) | |
;; ==> (#f "Exhausted all possible JSON value types: Failed to parse JSON number: Expected character '9', but found '[' instead") | |
;; | |
;; we know we are looking for a comma, so add a backtracking point after the string | |
;; return 1 >>= thing1 >>= thing2 >>= thing3 |
This file contains hidden or 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::fmt::Debug; | |
use std::marker::PhantomData; | |
enum Specialized {} | |
enum Generic {} | |
struct Thing<T, K = Generic> { | |
inner: T, | |
_phantom: PhantomData<K>, |
This file contains hidden or 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::ptr::NonNull; | |
use std::ops::{Deref, Drop}; | |
use std::mem::{MaybeUninit, ManuallyDrop}; | |
use std::sync::atomic::{AtomicUsize, Ordering}; | |
#[derive(Debug)] | |
pub struct StaticArc<T> { | |
inner: NonNull<StaticArcInner<T>>, | |
} |
This file contains hidden or 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
// no, this is not that useful | |
package main | |
import ( | |
"fmt" | |
"unsafe" | |
) | |
type Kind[T any] struct{} |
This file contains hidden or 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
{-# LANGUAGE NumericUnderscores #-} | |
module Bitlang | |
( compile | |
, evaluate | |
, generate | |
, ImageMeta(..) | |
, ExprMeta(..) | |
, Depth(..) | |
) where |