Skip to content

Instantly share code, notes, and snippets.

View khanage's full-sized avatar

Khan Thompson khanage

  • Melbourne, Australia
View GitHub Profile
exports.setHTML = function(el) {
return function (htmlElement) {
return function() {
el.innerHTML = '';
el.appendChild(htmlElement);
};
};
};
module Main where
import Data.Aeson
import Data.Aeson.Types
import Control.Applicative (Alternative(..))
data State = State { stateName :: String, stateNum :: Int } deriving (Eq, Show)
parseState :: Value -> Parser State
parseState = withObject "State" $ \v -> State <$> v .: "name" <*> v .: "id"
@khanage
khanage / FindPrimes.hs
Created March 28, 2017 10:54
Finding the first counter example to primes
module FindPrimes where
import Data.List ((\\))
setDifference = (\\)
primes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29
, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71
, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113
, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173
@khanage
khanage / Alacarte.hs
Created March 28, 2017 02:31
Where I'm at with datatypes a la carte
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverlappingInstances #-}
module Main where
data Expr f = In (f (Expr f))
foldExpr f (In t) = f (fmap (foldExpr f) t)
@khanage
khanage / openStashBranches.hs
Created September 5, 2016 13:56
Opens up the branches page for a given repo on osx with chrome installed
#!/usr/bin/env stack
-- stack --resolver lts-6.5 --install-ghc runghc --package turtle --package parsec --package text --package either
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.Trans.Either
import Data.Functor.Identity (Identity)
import Data.Monoid ((<>))
import Data.Text (pack)
import Text.Parsec as P
import Turtle hiding (Parser)