Skip to content

Instantly share code, notes, and snippets.

View countvajhula's full-sized avatar

Siddhartha Kasivajhula countvajhula

View GitHub Profile
@countvajhula
countvajhula / racket-search-and-replace.rkt
Last active October 30, 2025 20:24
Racket search-and-replace by binding (attempt)
;; Emacs Lisp
;; This uses a slightly modified version of Racket Mode's
;; `racket-xp-rename' to rename an identifier in a project *by
;; binding* rather than just textually by regex. The Racket Mode
;; function only works within a single module and doesn't have a
;; notion of a "project." So, the search and replace function below
;; uses Projectile's definition of a project --- i.e., the files
;; listed in the Git index for the current repo via
;; `projectile-project-files' --- to apply `racket-xp-rename'
@countvajhula
countvajhula / langs-that-fit-in-your-head.diff
Created December 11, 2024 02:58
#langs that fit in your head -- diff from initial version
-(Written for the Racket community for Day 8 of the Racket Advent Calendar)
+This post was written for Day 8 of the Racket Advent Calendar. “#lang” is a Racket term referring to declaring the programming language in use, and this post uses Racket as a platform to discuss one approach to writing good programming languages. I’ve made an effort to explain the Racket-specific ideas as they are introduced, so if you are interested in language design but aren’t a Racketeer, I hope you’ll still read it and that you’ll find it interesting.
When a way of expressing a complex idea becomes small enough to fit in your head and doesn’t require special effort on your part to remember, it has, in a useful sense, become a language.
-Take Racket's module system, for example. By just writing "require," which is of course what we mean to do, we gain the ability to describe with great and effortless nuance in just what manner we mean to include those modules -- whether to retain the names of the included definitions or change
@countvajhula
countvajhula / module-load.md
Last active September 30, 2022 18:59
Understanding Racket module load time contributions

The Setup

This uses the codeloader tool to generate lots of dummy code. The same aggregate generated code is either contained in a single module or distributed across N=500 modules, and there are two client modules, main-combined.rkt and main-separate.rkt that require either the former or the (myriad) latter. The tests below are run on these "main" modules.

$ ./filecreator 500

Results

@countvajhula
countvajhula / loadlib.rkt
Last active July 12, 2022 01:32
Module load time tester
#!/usr/bin/env racket
#lang cli
(require racket/port
racket/format)
#|
This works by:
1. Running `racket -l <module_name>` and `racket -l racket/base` independently
2. Subtracting the latter from the former.
@countvajhula
countvajhula / RRFI: Universal Equality.rst
Last active March 19, 2022 19:06
RRFI: Two-Level Universal Scheme for Equality
@countvajhula
countvajhula / equality.org
Created February 4, 2022 00:38
Rhombus Meeting: Interface to elementary relations such as equality

0. Motivation

We all want Rhombus to succeed

Not a juggernaut but a flagship

Syntax is one aspect to experiment with and improve

Coherence is another

1. Theoretical stuff

Functions express any notion of equality

That’s why we intuitively reach for functions to tailor equality

“it makes no difference to me”

“if it’s all the same to you, …”

@countvajhula
countvajhula / AoC 2021 Day 1.rkt
Created December 6, 2021 04:09
AoC 2021 Day 1
#lang racket
(require qi
"util.rkt")
(define input (read-input-file "1.txt"))
(define depths
(parse-input input))
@countvajhula
countvajhula / vim-normal-grammar.md
Last active April 20, 2022 00:49
A Grammar for Vim's Normal Mode

A Grammar for Vim's Normal Mode

A rough attempt at characterizing Vim's Normal Mode grammar that I made while writing this Vim series. See the bibliography there for more context.

Notation: | means or, [] means optional, * means zero or more, <> means literal class (e.g. <number> could expand to 1, 2, etc.), ... means there are more instances not enumerated here (these would need to be fleshed out to get a complete grammar).

It could be interesting to use a grammar like this one to organize an interactive Vim cheatsheet.

normal-command = motion-form

| verb-phrase

@countvajhula
countvajhula / gist:87512d3a7ed3ee2b5b55c9f45ac7a871
Last active November 4, 2020 20:08
scribble error with reproviding a required function
examples: exception raised in example
error: "dynamic-require: name is protected\n name: 'syntax-local-expand-observer\n module: #<resolved-module-path:'#%expobs>"
context...:
do-error
.../scribble/eval.rkt:308:23: with-handlers-handler102
.../private/more-scheme.rkt:163:2: select-handler/no-breaks
.../scribble/eval.rkt:356:9
.../private/map.rkt:40:19: loop
[repeats 6 more times]
.../private/manual-vars.rkt:218:40