Skip to content

Instantly share code, notes, and snippets.

View rocketnia's full-sized avatar

Ross Angle rocketnia

View GitHub Profile
@rocketnia
rocketnia / gist:68378b9e7f4437054e3dbd2a44303a34
Created February 14, 2023 15:00
Using the Rieger-Nishimura lattice as a decision procedure failure result
given (p || ~p)
prove (~~p -> p)
proof :: (p + (p -> 0)) -> (((p -> 0) -> 0) -> p)
proof p_or_p0 p0_0 =
case p_or_p0
Left p =>
p
Right p0 =>
@rocketnia
rocketnia / derived-equality-interface.rkt
Last active April 8, 2022 03:29
Defining a key-function-based equality interface over the top of `gen:equal+hash`.
#lang racket
; This code is in service of @countvajhula's Rhombus equality RRFI at
; https://github.com/countvajhula/rhombus-prototype/tree/master/rrfi
; and parts of it should probably be copied into the proof of concept in that
; repo.
(require racket/generic)
(require rackunit)
@rocketnia
rocketnia / mutation.rkt
Created March 29, 2022 22:41
Implementing mutation using delimited control
#lang racket/base
(require (only-in racket/control reset shift))
(require (only-in racket/match match match-let*))
(define (my-set! pointer value)
(shift k
`(my-set! ,pointer ,value ,k)))
@rocketnia
rocketnia / curried-macro-test-case.rkt
Last active September 30, 2020 06:34
Hygiene for a curried macro: A failing test that a Racket macro (M1) generated by a macro (M2) can bind a variable passed to M1.
#lang racket
(require rackunit)
; Hygiene for a curried macro
; I've been experimenting with a custom system of managed local
; variables, and I came up with a hygiene test case that was failing.
; So then I tried the same test case with plain Racket variables, and
; it failed that way too. Here's a minimalistic example.
@rocketnia
rocketnia / compound-codegen.md
Last active May 23, 2020 04:32
An example of using compound expressions for readability of code-generating code.

I find compound unquoted expressions to be pretty good for the readability of a code generator. I think this is a good example (from the current version of html-render.rkt):

`(div ([class ,(if top?
                   "tocviewlist tocviewlisttopspace"
                   "tocviewlist")])
   ,(if top? `(div ([class "tocviewtitle"]) ,header) header)
   ,(if (null? children)
      ""
      `(div ([class ,(cond
@rocketnia
rocketnia / lazy-merge-sort.rkt
Created November 18, 2019 07:53
A benchmark comparing Rebellion's `sorting` to a lazy merge sort. See https://github.com/jackfirth/rebellion/issues/301 for context.
#lang racket/base
(require racket/contract/base)
(provide
(contract-out
[in-merge-sorted (-> (-> any/c any/c boolean?) stream? stream?)]))
(require racket/match
racket/promise
@rocketnia
rocketnia / lazy-merge-sort.rkt
Created November 13, 2019 04:08
A lazy merge sort of Racket streams, potentially useful for Rebellion
#lang racket/base
(require racket/contract/base)
(provide
(contract-out
[in-merge-sorted (-> (-> any/c any/c boolean?) stream? stream?)]))
(require racket/match
racket/promise
kick.
that wall.
jump.
and do not fall.
Ice LESS~~ It's the stunt we've gotta do.
To get the fastest SPEEDrun it's what we NEED to train up to.
Up Boomer's tower, practice for seven hours gotta jump, hold
And kick off that loft
@rocketnia
rocketnia / transducers.rkt
Created September 4, 2018 18:15
Stream fusion infrastructure for Racket for discussion with Jack Firth.
#lang racket
; transducers
;
; Data structures, algorithms, and utilities for fusable stream
; manipulations.
;
; Inspired by a conversation with Jack Firth, who was using the
; terminology of "iterators," "collectors," and "transducers," with
; design goals that involved allowing certain clients to minimizing
@rocketnia
rocketnia / index.md
Last active October 28, 2018 07:30
Cene namespace notes

Cene namespace notes

Stream of consciousness 1: Several ideas

See also the Gist "Cene packages": https://gist.github.com/rocketnia/cac8aa719470f3b6fa4b49e1131270f9

Given a "contribute function" and "contribute argument" based open-world-assumption extension framework, and given the ability to define the same thing more than once if specifying a dex at the same time, it's possible to define transitive closure relations where the entries are contributed as arguments: Contribute a function, have it contribute another function each time it gets an argument, and have that function contribute an argument if the two arguments imply something.

(Rather than just specifying a dex with each definition, we could specify something less general than a merge but more general than a (merge-by-dex ...). Not only would it be idempotent like a merge, but it would also ensure that the result was "backwards compatible" with both inputs -- behaving exactly alike in all non-error cases, and exhibiting no more errors than