Skip to content

Instantly share code, notes, and snippets.

hdgarrood / Derivative.hs
Created Aug 7, 2014
finding a derivative in haskell, first attempt
View Derivative.hs
module Derivative where
data Expr = X -- variable
| S Integer -- scalar
| Expr :+: Expr -- sum
| Expr :*: Expr -- product
| Expr :^: Integer -- exponent
deriving (Show, Eq)
hdgarrood /
Last active Aug 29, 2015
packet filtering + vagrant

I wanted to rewrite ports on incoming tcp packets (on OSX) on my host machine, so that a web server on a guest vm appears to be running on the host.

Incoming packets on port 80 should get rewritten to 8080, and incoming packets on port 443 should get rewritten to port 8443.

I asked about this on hipchat a few days ago and nobody seemed to know the answer - I recently found it, and so decided to share in case this is useful to anybody.

View Coercible.purs
module Coercible where
foreign import unsafeCoerce
"function unsafeCoerce(x) { return x }" :: forall a b. a -> b
class Coercible a b
coerce :: forall a b. (Coercible a b) => a -> b
coerce = unsafeCoerce
View harry-garrood-gsoc-proposal.markdown

Harry Garrood

GSOC proposal: Pursuit enhancements

PureScript is a language similar to (and written in) Haskell, which compiles to JavaScript. Due to PureScript's expressive type system, functions and data can provide lots of information and even guarantees about their structure and behaviour, through just their type signatures. For example, types can capture

hdgarrood / purescript-maybe.txt
Last active Aug 29, 2015
Potential Hoogle input format for PureScript
View purescript-maybe.txt
@name purescript-maybe
@version 0.2.2
module Data.Maybe where
-- | <p>The <code>Maybe</code> type is used to represent optional values and can be seen as
-- | something like a type-safe <code>null</code>, where <code>Nothing</code> is <code>null</code> and <code>Just x</code>
-- | is the non-null value <code>x</code>.</p>
data Maybe a
View gist:9c4e63e6611656bf9c2d

upload process

  • user runs pulp publish, or something
  • JSON dump is generated by psc-package-upload
  • Uploaded to
  • Verification URL sent back in response, and printed to stdout
  • User visits verification URL in browser and is authenticated via GitHub OAuth
  • After authentication, HTML is generated etc and the package appears on pursuit.
hdgarrood / Main.purs
Last active Aug 29, 2015
Infix declarations
View Main.purs
module Main where
import Debug.Trace
data Two a b = Two a b
instance showTwo :: (Show a, Show b) => Show (Two a b) where
show (Two x y) = "(" <> show x <> " : " <> show y <> ")"
-- Non-associative
View Data.Traversable.js
// module Data.Traversable
exports.traverseArrayImpl = function(apply) {
return function(map) {
return function(pure) {
return function(consArray) {
return function(f) {
var buildFrom = function(x) {
return function(ys) {
View week-1.markdown

Pursuit GSOC: Week 1

I'm going keeping a blog of progress on my Google Summer of Code project this summer, which is various enhancements to the PureScript code search tool Pursuit.

I have managed to get quite a bit done already, since I had been contributing to PureScript (and Pursuit in particular) for a while before I even applied for Google Summer of Code. So, for the first entry, I'm just going to go over what's been done so far: