Skip to content

Instantly share code, notes, and snippets.

View hdgarrood's full-sized avatar
💭
All of my personal repos are unmaintained

Harry Garrood hdgarrood

💭
All of my personal repos are unmaintained
View GitHub Profile
@hdgarrood
hdgarrood / Derivative.hs
Created August 7, 2014 01:52
finding a derivative in haskell, first attempt
module Derivative where
data Expr = X -- variable
| S Integer -- scalar
| Expr :+: Expr -- sum
| Expr :*: Expr -- product
| Expr :^: Integer -- exponent
deriving (Show, Eq)
@hdgarrood
hdgarrood / vagrant-packet-filtering.md
Last active August 29, 2015 14:05
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.

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
@hdgarrood
hdgarrood / harry-garrood-gsoc-proposal.markdown
Last active August 29, 2015 14:17
PureScript GSOC proposal

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
hdgarrood / recipes-i-used.md
Last active August 29, 2015 14:17
Recipes
@hdgarrood
hdgarrood / purescript-maybe.txt
Last active August 29, 2015 14:18
Potential Hoogle input format for PureScript
@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
@hdgarrood
hdgarrood / gist:9c4e63e6611656bf9c2d
Last active August 29, 2015 14:19
Pursuit thoughts

upload process

  • user runs pulp publish, or something
  • JSON dump is generated by psc-package-upload
  • Uploaded to pursuit.purescript.org
  • 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
hdgarrood / Main.purs
Last active August 29, 2015 14:21
Infix declarations
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
// 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) {
@hdgarrood
hdgarrood / week-1.markdown
Last active August 29, 2015 14:22
Pursuit notes

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: