Skip to content

Instantly share code, notes, and snippets.

View rampion's full-sized avatar

Noah Luck Easterly rampion

  • Mercury Technologies
View GitHub Profile
@rampion
rampion / Day11.hs
Created December 11, 2017 22:32
AOC11-1
{-# LANGUAGE LambdaCase #-}
module Main where
{-
--- Day 11: Hex Ed ---
Crossing the bridge, you've barely reached the other side of the stream when a
program comes up to you, clearly in distress. "It's my child process," she says,
"he's gotten lost in an infinite grid!"
Fortunately for her, you have plenty of experience with infinite grids.
@rampion
rampion / Day8.hs
Created December 8, 2017 21:28
AOC8-1
{-# OPTIONS_GHC -Wno-name-shadowing #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE LambdaCase #-}
module Main where
import qualified Data.Map.Strict as M
import qualified Data.List as L
import Data.Maybe (fromMaybe)
{-
--- Day 8: I Heard You Like Registers ---
@rampion
rampion / FFunctor.hs
Created October 27, 2017 03:18
Alternate definition of FApplicative aka FMonoidal
{-# OPTIONS_GHC -Wall -Werror -Wextra #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilyDependencies #-}
print "ab"
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
module Fin where
data Nat = Z | S Nat
newtype Fin (n :: Nat) = Fin { unFin :: Int }
z^z'
z^ω = ω
z^(ω ^(1 + α) * z') = z^(ω * ω^α * z') = (z^ω)^(ω^α * z') = ω^(ω^α * z')
(ω^α)^α' = ω^(α*α')
(ω * ω^α * x) ^ (ω * ω^β * y) = ω^((1+α) * ω^(1+β) * y)
x ^ (ω * ω^β * y) = (x^ω)^(ω^β * y) = ω^(ω^β * y)
(ω * ω^α * x) ^ y = ω * ω^α * ω * ω^α * ... ω * ω^α * x
= ω^((1+α)*y) * x
@rampion
rampion / hellox3.cpp
Last active August 9, 2016 02:47
hellohellohello
#include <iostream>
int main() {
auto s = "Hello World\n";
std::cout << s << s << s;
}
@rampion
rampion / 0.md
Last active April 18, 2016 19:19
Composing bijections, surjections, and injections

It's occasionally useful to consider a slightly richer function definition than ->, one where you can reason about the preimage of the function's codomain.

One approach is to bundle each -> with another function describing the preimage:

data Bidirectional p q a b = Bidirectional
  { forwards :: p a b
  , backwards :: q b a
  }
@rampion
rampion / Intro.md
Last active April 13, 2016 04:02
The ObserverT monad transformer [check for interest]

A couple months ago, I had an idea for a monad transformer, and sunk a good deal of time into figuring out how to make it work. I started getting it ready for Hackage before I realized I didn't have an immediate use case for it, and so I didn't have a good sense for what sensible defaults would be. I put the project aside to work on other things and let my brain churn on it.

What I'm going to do here is describe the idea and some implementation notes to get a sense of how useful it'd be as a package, so I know whether it's worth my time.

// !debit [field] [action] decrements [field] and runs [action] if [field] > 0
//
// examples (note the '\' to prevent the &{...} from running immediately)
//
// !debit classactionresource1 %\{Coll|classaction1}
//
// !debit repeating_classresources_-KBB1UHdMK0ygfFM3AtV_ClassResourceTotal %\{Coll|classaction2}
//
// (I don't know a better way to get repeating classaction ids than inspecting the page)
var DebitModule = DebitModule || (function(){ "use strict";