Skip to content

Instantly share code, notes, and snippets.

View steshaw's full-sized avatar
👨‍💻
Loves programming languages

Steven Shaw steshaw

👨‍💻
Loves programming languages
View GitHub Profile
@szabgab
szabgab / tail.rs
Last active September 28, 2025 22:57
tail -f in rust
use std::{env, path::PathBuf, time::Duration};
use tokio::fs::File;
use tokio::io::{AsyncBufReadExt, AsyncSeekExt, BufReader, SeekFrom};
use tokio::time::sleep;
#[tokio::main]
async fn main() {
let filename = get_filename();
tail_file(filename).await;
}
trait Compiler:
type Env = Map[String, BigDecimal]
@throws[ParserError]
def compile(formula: String): Env => BigDecimal
import scala.quoted.*
type Env = Map[String, BigDecimal]
type E[A] = Expr[Env] ?=> Expr[A]
@AndrasKovacs
AndrasKovacs / TwoStageRegion.md
Last active July 26, 2025 08:26
Lightweight region memory management in a two-stage language
@steshaw
steshaw / fpmax.scala
Created September 26, 2023 06:05 — forked from jdegoes/fpmax.scala
FP to the Max — Code Examples
package fpmax
import scala.util.Try
import scala.io.StdIn.readLine
object App0 {
def main: Unit = {
println("What is your name?")
val name = readLine()
@AndrasKovacs
AndrasKovacs / ZeroCostGC.md
Last active July 8, 2025 02:56
Garbage collection with zero-cost at non-GC time

Garbage collection with zero cost at non-GC time

Every once in a while I investigate low-level backend options for PL-s, although so far I haven't actually written any such backend for my projects. Recently I've been looking at precise garbage collection in popular backends, and I've been (like on previous occasions) annoyed by limitations and compromises.

I was compelled to think about a system which accommodates precise relocating GC as much as possible. In one extreme configuration, described in this note, there

@steshaw
steshaw / ubuntu-setup.md
Last active March 21, 2023 01:18
Ubuntu desktop setup

Setting up a fresh Ubuntu machine

Start with Ubuntu

Install Ubuntu Desktop 22.04, encrypted ZFS, with minimal packages.

Install OpenSSH

We may want to do the rest of the installation/configuration from our laptop over ssh, so:

@AndrasKovacs
AndrasKovacs / HOASOnly.hs
Last active April 11, 2025 20:56
HOAS-only lambda calculus
{-# language BlockArguments, LambdaCase, Strict, UnicodeSyntax #-}
{-|
Minimal dependent lambda caluclus with:
- HOAS-only representation
- Lossless printing
- Bidirectional checking
- Efficient evaluation & conversion checking
Inspired by https://gist.github.com/Hirrolot/27e6b02a051df333811a23b97c375196
@andreabedini
andreabedini / plan-to-datalog.jq
Created December 15, 2022 08:18
plan-to-datalog.jq
#!/usr/bin/env -S jq -f -r
#
# This jq scripts transforms cabal's plan.json file into a series of fact that souffle can interpret.
#
# Example use
#
# $ ~/plan-to-datalog.jq <dist-newstyle/cache/plan.json >plan.dl
#
# Then create a file query.dl
#
@raulraja
raulraja / 0.SIP.md
Last active August 3, 2025 10:24
Scala 3 Continuations

Pre-SIP: Suspended functions and continuations in Scala 3.

This Pre-SIP post proposes continuations as a new language feature in Scala 3.

It has been prepared by Jack Viers, Raul Raja and reviewed by the Scala 3 team at 47 Degrees. This doc is intended to be used as a way to gather community feedback and foster discussion.

Motivation

Our observation in the industry and among our peers is that most programming in Scala today that involves async or I/O-based programs targets a monadic indirect boxed style.

@ners
ners / Schedule.hs
Last active May 20, 2022 02:50
A Haskell program that parses Doodle responses and selects the two best time slots such that as many participants as possible may attend.
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Data.Aeson (FromJSON, Object, Value (..), eitherDecodeFileStrict, parseJSON, (.:))