This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| | |
- Example of using free constructions to build a flexible little compiler. | |
- | |
- The goal here is not necessarily efficiency but readability and flexibility. | |
- | |
- The language grammar is represented by an ADT; however, instead of | |
- recursively referring to itself it instead references a type variable. | |
- | |
- We derive instances of 'Functor' and 'Traversable' for this type. | |
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | This can be run with | |
-- > cabal run conway.hs | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE DeriveFoldable #-} | |
{- cabal: | |
build-depends: base, Stream, JuicyPixels, comonad | |
-} | |
import Prelude hiding (head, tail, repeat, take) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### | |
# Script to launch jackd and reroute PulseAudio through it. And optionally | |
# start fluidsynth. | |
# | |
# READ THE NOTES PLEASE | |
### | |
# Usage (assuming this script is named `audio`, is in your PATH, and is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PID controller in Haskell | |
=== | |
A major project I want to embark on at some point in the future is making a | |
quadrotor. I've made one before but I was at the mercy of a lot of off-the-shelf | |
software that I'm not altogether sure was entirely correct, either. | |
So I want to eventually program a quadrotor (or similarly awesome robot thing) | |
and I would really enjoy doing it in Haskell. It has a low footprint and is | |
already used in other real time settings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readFile } from "fs/promises"; | |
import { createInterface } from "readline"; | |
import type { Interface } from "readline"; | |
import { CESKM, parse_cbpv, scalar, continuation, topk } from "precursor-ts"; | |
import type { State, Value, Store } from "precursor-ts"; | |
import { | |
createMachine, | |
state, | |
transition, | |
reduce, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* outputs: | |
* a { a: 3, b: 6, c: 12 } | |
* b { a: 5, b: 10, c: 18 } | |
* c { a: 8, b: 16, c: 27 } | |
* { a: '25', b: '196', c: '900' } | |
* c 900 | |
*/ | |
// todo: use type system to statically verify the key exists in the object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { _, Functor, Fix, _in, cata, Algebra } from './base'; | |
import { strict as assert } from 'assert'; | |
// The type parameter goes where the grammar would otherwise reference itself. | |
type ArithF<A> | |
= { tag: 'add' ; lhs: A ; rhs: A } | |
| { tag: 'mul' ; lhs: A ; rhs: A } | |
| { tag: 'num' ; n: number } | |
| { tag: 'paren' ; e: A } ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang typed/racket | |
(provide None | |
Just | |
Opt | |
maybe | |
neq? | |
Parser | |
lit | |
try-parse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Hask-- I mean, psilo with no real typeclasses and one virtual typeclass. | |
; Inspired by [1], this is an exploration of representing all typeclasses | |
; through one distinguished class. | |
; | |
; This version of psilo does not have "real" typeclasses. However faking them | |
; with explicit dictionary passing does seem to correctly infer and check the | |
; constraints. | |
; | |
; The goal then is to figure out how best to represent "real" typeclasses as a | |
; distinguished feature in the language implementation given that we are |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- cabal: | |
build-depends: base | |
-} | |
module ContT | |
( ContT | |
, reset | |
, shift | |
, liftIO | |
) |