Skip to content

Instantly share code, notes, and snippets.

Avatar
🏂
Gleaming the hypercube

Chris Pressey cpressey

🏂
Gleaming the hypercube
View GitHub Profile
View .bash_aliases
# encoding: UTF-8
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
export PATH="$HOME/.cabal/bin:$HOME/.local/bin:$PATH"
export EDITOR=nano
alias unpyc="find . -name '*.pyc' -exec rm -f {} \;"
alias rsyncavd="rsync --archive --verbose --delete"
alias git-savepatch='git diff >'
alias chintzy-httpd='python2 -m SimpleHTTPServer'
@cpressey
cpressey / OperationalSansGADTs.hs
Last active Oct 8, 2020
Operational monad sans GADTs
View OperationalSansGADTs.hs
module OperationalSansGADTs where
import Control.Monad (liftM, ap)
--
-- Adapted from "The Operational Monad Tutorial":
-- https://apfelmus.nfshost.com/articles/operational-monad.html
--
data Program instr a b = Then (instr a) (a -> Program instr a b)
View PipelineCombinators.hs
module PipelineCombinators where
import Data.Either
import qualified Data.Functor.Alt
import qualified Data.Function
import qualified Control.Monad
--
-- Combinators for pipelines. Each of these functions takes one or more
-- parameters and yields a combinator that is intended to map functions
@cpressey
cpressey / Future directions for SixtyPical.md
Last active Aug 10, 2020
Future directions for SixtyPical
View Future directions for SixtyPical.md

Future directions for SixtyPical

SixtyPical has reached a mature stage of development. There are small features that could be added, but they are minor compared to the main features (abstract-interpretation/symbolic-execution/flow-typing-based static analysis and optimization of low-level 6502 programs). So the question arises -- what would be next for SixtyPical?

@cpressey
cpressey / Calling an anonymous function directly in various languages.md
Last active Jun 1, 2020
Calling an anonymous function directly in various languages
View Calling an anonymous function directly in various languages.md

Just a little survey of what code to create an anonymous function and immediately call it looks like in a handful of high-level languages. All of these expressions should evaluate to 10.

Language Code
Python (lambda x: x+1)(9)
Ruby (lambda {|x| x+1}).call(9)
Lua (function(x) return x+1 end)(9)
Erlang (fun(X) -> X+1 end)(9)
Haskell (\x -> x+1)(9)
@cpressey
cpressey / Some Notes on Software Preservation.md
Last active Mar 24, 2020
Some Notes on Software Preservation
View Some Notes on Software Preservation.md
@cpressey
cpressey / Programming Language Feature Desiderata.md
Last active Feb 27, 2021
Programming Language Feature Desiderata
View Programming Language Feature Desiderata.md

Programming Language Feature Desiderata

Draft, very draft

This is a list of programming language features that I like (sometimes contrasted with features I don't like) with the hopeful goal of informing a future language design.

For sake of background: almost all of the code I write in my day job

@cpressey
cpressey / dollar.scm
Created Aug 27, 2019
How Haskell's infix $ operator might look in Scheme
View dollar.scm
(define reduce
(lambda (subject complete-rules rules generation-id)
(if (null? rules)
subject
(let* ((rule-pair (car rules))
(rest-of-rules (cdr rules))
(pattern (car rule-pair))
(replacements (cdr rule-pair))
(new-gen-id (+ generation-id 1))
(new-subject (apply-rule subject pattern replacements generation-id)))
View Wagon.md

NOTE: this document is out of date. See the Wagon distribution for the latest version of this document.

Wagon

In a conventional concatenative language, every symbol represents a function which takes program states to program states, and the program is a concatenation (sequential composition) of such functions. This is fine when it comes to manipulating state, but what about control?

View Odd.hs
-- implementation of https://esolangs.org/wiki/An_Odd_Rewriting_System
-- I, Chris Pressey, hereby place this source code into the public domain.
import Data.Char
-- A program in An Odd Rewriting System consists an alphabet of symbols,
-- each of which belongs to one of two categories (an odd symbol or an even symbol),
-- except for a special halt symbol that appears in neither category;
-- two definitions for each symbol (an odd definition and an even definition);
-- and an initial string. Both the initial string, and each definition, is simply a