Skip to content

Instantly share code, notes, and snippets.

Nathan Howell NathanHowell

Block or report user

Report or block NathanHowell

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
@NathanHowell
NathanHowell / please-no.hs
Created Jun 23, 2015
Really terrible HTTP CONNECT proxy for Haskell/WAI
View please-no.hs
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Concurrent (forkIO, newEmptyMVar, putMVar, takeMVar)
import Control.Exception (finally)
import Control.Monad
import Control.Monad.Trans (liftIO)
import Data.ByteString.Char8 ()
import qualified Data.ByteString as B
import Data.Monoid
@NathanHowell
NathanHowell / JsonSchemaRDD.scala
Created Nov 15, 2014
SchemaRDD to row JSON conversion
View JsonSchemaRDD.scala
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
View loop.hs
foo :: Int -> Int
foo x | x > 0 = x -1
foo x | otherwise = 0
@NathanHowell
NathanHowell / generic-fold.hs
Last active Aug 29, 2015
Foldable for GHC.Generic instances
View generic-fold.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
import GHC.Generics
import Data.Foldable as Foldable
import Data.Monoid
View wrap-that-timer.hs
{-# LANGUAGE RankNTypes #-}
import qualified GHC.Event
data TimerManager2 = TimerManager2
{ registerTimeout :: Int -> GHC.Event.TimeoutCallback -> IO GHC.Event.TimeoutKey
, updateTimeout :: GHC.Event.TimeoutKey -> Int -> IO ()
, unregisterTimeout :: GHC.Event.TimeoutKey -> IO ()
}
@NathanHowell
NathanHowell / centos7-upgrade.sh
Created Jul 26, 2014
Upgrade CentOS 6.5 to 7.0.1406 using the prerelease upgrade tools
View centos7-upgrade.sh
#!/bin/bash
set -e
cat > /etc/yum.repos.d/upgrade.repo <<END
[upgrade]
name=upgrade
baseurl=http://dev.centos.org/centos/6/upg/x86_64/
enabled=1
gpgcheck=0
END
View ReaderT
connectionUrl :: Monad m => ReaderT m Config B.ByteString
-- withConnection
-- :: (Database.PostgreSQL.Simple.Internal.Connection -> IO c)
-- -> ReaderT Config IO c
withConnection f = do
url <- connectionUrl
liftIO $ bracket (connectPostgreSQL url) close f
@NathanHowell
NathanHowell / error.txt
Last active Jan 1, 2016
GNTD regressions in GHC HEAD. This typechecks on 7.6.3 but not on 7.7.20131217 unless ImpredicativeTypes are enabled.
View error.txt
[1 of 1] Compiling Repro ( repro.hs, interpreted )
repro.hs:24:13:
Cannot instantiate unification variable ‛b0’
with a type involving foralls:
(forall r. (a1 -> IO r) -> IO r) -> DecodeAST a1
Perhaps you want ImpredicativeTypes
In the expression:
GHC.Prim.coerce
(anyContToM ::
@NathanHowell
NathanHowell / gist:6880968
Created Oct 8, 2013
Convert a type to a nested tuple, preserving left-to-right ordering via CPS conversion.
View gist:6880968
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Typeable
convert :: (Typeable t, Typeable b) => (forall a . Typeable a => a -> r) -> [t] -> b -> r
convert f (x:xs) b = convert f xs (x, b)
convert f [] b = f b
View .gitignore
.cabal-sandbox/
dist/
cabal.config
cabal.sandbox.config
.*.swp
You can’t perform that action at this time.