View list_essay_code.js
'use strict';
/**
* Our little list implementation
*/
///// The foundation
let nil = (f) => (x) => x;
let cons = (h) => (t) => (f) => (x) => f(h)(t(f)(x));
let foldr = (list) => (f) => (x) => list(f)(x);
View module_boilerplate.js
/**
* ECMAScript module boilerplate
*
* (c) 2016 Gatlin Johnson <gatlin@niltag.net>
* with significant credit to github user @cwmyers
*
* Follow this template and your module will be compatible with browsers or any
* number of sophisticated ES dependency systems.
*
* INSTRUCTIONS
View my_prelude.hs
{- * Foundational functions -}
id :: a -> a
id x = x
const :: a -> b -> a
const x y = x
fix :: (a -> a) -> a
fix f = f (fix f)
View orca.hs
{-
This came from looking at the source for the orc package on hackage.
I wanted to know why it works, and to see if I can come up with an
alternative implementation which does cool things, and possibly provide
a mechanism for orchestrating non-linear tube computations.
-}
-- | Pilfered from the orc package on Hackage.
-- The original is specialized to one MonadIO instance.
-- Also this looks suspiciously like a continuation monad.
View frp_free.hs
import Control.Applicative
import Data.Time (UTCTime, getCurrentTime)
import Control.Monad.Trans.Free
import Control.Comonad
import Control.Comonad.Trans.Cofree
import Data.Functor.Identity
type Next = IO
View hackagedocs
#!/usr/bin/env bash
###
# hdoc
# (c) Gatlin Johnson <gatlin@niltag.net>
#
###########
# Available under the following license:
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
View tube_coro.hs
{-# LANGUAGE Rank2Types #-}
import Prelude hiding (break, take)
import Tubes
import Data.Functor.Identity
import Control.Monad (forever)
{- |
This just holds a value and hands it over when the tube asks, or replaces it
with whatever a tube yields.
View skiing.js
/**
* Run with node.js:
*
* $> node skiing.js
*
* For a decent overview of what S and K and the rest of all this is:
*
* https://en.wikipedia.org/wiki/SKI_combinator_calculus
*
* This is one of those things where the actual theory isn't difficult, but
View skiing.rkt
#lang racket
; We begin with the S and K combinators
(define S (λ (x)
(λ (y)
(λ (z)
((x z) (y z))))))
(define K (λ (x) (λ (y) x)))
View nn_repa.hs
{-
To run:
1. Ensure you have repa and repa-algorithms installed
2. ghc --make nn_repa.hs -O2
3. ./NN +RTS -s
The `+RTS -s` part prints out a summary of runtime statistics.
-}