Skip to content

Instantly share code, notes, and snippets.

lalaithion /
Last active May 24, 2021 03:17
Reproducing code for Double Unroot issue
// [dependencies]
// gc = { version = "0.4", features = ["derive"] }
// rpds = "0.9.0"
// fails with `thread 'scope::tests::test' panicked at 'Can't double-unroot a Gc<T>'`
use core::fmt::{Debug, Formatter, Result};
use gc::{Finalize, Gc, Trace};
use rpds::HashTrieMap;
use std::io::Write;
View minimal.fut
type sizetwice [n] = {
array: [n][n]i64
let make_sizetwice (n: i64): sizetwice [n] = {array = replicate n (iota n)}
let consume_sizetwice [n] (x: sizetwice [n]): i64 = reduce (+) 0 (map (reduce (+) 0) x.array)
-- > consume_sizetwice (make_sizetwice 3i64)
View perlin.fut
import "lib/"
-- We'll need a random number generator. We don't need any good guarantees,
-- so we use the fastest one.
module dist = uniform_real_distribution f32 minstd_rand
-- Let's define some aliases for readability.
let split = minstd_rand.split_rng
View bomb.hs
f :: Int -> Bool
f i = 23 == foldr ((+) . abs) i [-5..5]
main = do
putStrLn "Can you beat my Haskell puzzle?"
x <- getLine
if f (read x) then putStrLn "You beat my Haskell puzzle!" else putStrLn "Boom"
use std::rc::Rc;
use std::fmt::{Display, Debug, Error, Formatter};
/// Because we are dealing with immutable data, we shouldn't ever need the
/// owned variant of Lazy or the mutable version of Thunk.
use thunk::LazyRef;
use thunk::Thunk;
use crate::ListCell::*;