Skip to content

Instantly share code, notes, and snippets.

Harry Garrood hdgarrood

Block or report user

Report or block hdgarrood

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View load-from-cwd-or-npm@3.0.2.js
'use strict';
const {dirname, isAbsolute, join, resolve} = require('path');
const {existsSync} = require('fs');
const {PassThrough} = require('stream');
const inspectWithKind = require('inspect-with-kind');
const npmCliDir = require('npm-cli-dir');
const optional = require('optional');
const resolveFromNpm = require('resolve-from-npm');
View DataTypes.purs
module DataTypes where
data Foo = Foo
mkFoo = Foo
data Bar = Bar
data Baz = Baz1 | Baz2

Why there can be no EuclideanRing b => EuclideanRing (a -> b) instance

One of the defining features of a EuclideanRing is that you can divide any pair of elements, as long as the divisor is nonzero. Specifically, if you have a euclidean ring R, with x, y in R, and y /= zero, we need to have x = (x / y) * y + (x `mod` y).

We do have a Ring b => Ring (a -> b) instance, where multiplication is defined as follows:

hdgarrood / calc.js
Last active Aug 2, 2017
perf impact of reordering declaration ref list
View calc.js
var master = [15.985, 15.774, 16.664, 16.111, 15.889, 15.603, 15.598, 15.690, 15.602, 16.159];
var reordered = [15.831, 16.182, 16.519, 15.383, 15.936, 15.888, 15.645, 15.775, 15.749, 16.076];
function mean(arr) {
return arr.reduce(function(x,y) { return x + y; }) / arr.length;
function variance(arr) {
var m = mean(arr);
hdgarrood /
Last active May 16, 2017
An extremely naive implementation of the simplex algorithm.
from collections import namedtuple
import numpy as np
# This is an implementation of the version of the simplex algorithm we are
# expected to execute by hand in LPMS. There is just one important difference:
# because python and numpy use zero-based indexing, this does too. So for
# example you need to subtract 1 from each element of your basic and nonbasic
# sets.
LPState = namedtuple("LPState", ["basic", "nonbasic"])

Haskell projects with lots of dependencies on Travis CI

If your Haskell project has lots of dependencies, you can find yourself reaching the timeout while compiling them - the free service has a timeout of 50 minutes. How do we address this?

First, a quick reminder of build statuses in Travis CI:

All builds finish with one of four possible statuses: succeeded, failed, errored, or (manually) cancelled. The difference between a failed and errored

View awkward-records.patch
a9d20f4 Add test for generic deriving with awkward records (Harry Garrood, 54 seconds ago)
diff --git a/examples/passing/RecordLabels.purs b/examples/passing/RecordLabels.purs
new file mode 100644
index 0000000..b58a4bd
--- /dev/null
+++ b/examples/passing/RecordLabels.purs
@@ -0,0 +1,5 @@
+module Main where


First you'll need a docker install:


After installing Docker, we'll run a PureScript psci session by running the image. The -it flags allocate a pseudo tty and make it interactive. We're pulling the image from the default docker hub, so the images are here and the code that builds them is on GitHub

docker run -it biscarch/purescript:
View Main.purs
module Main where
Data.List (List)
Data.List as List
Control.Monad as Monad
Control.Monad.Eff.Console as Console
main = Console.log (show "hello world")
You can’t perform that action at this time.