Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am nathanhowell on github.
  • I am nathanhowell (https://keybase.io/nathanhowell) on keybase.
  • I have a public key ASC5cgtZMOLRHjV1qLg1TtuAv8xI1wjwmwqhvv9eUn7ybAo

To claim this, I am signing this object:

@NathanHowell
NathanHowell / Dockerfile
Created July 28, 2017 21:52
Example of multistage Docker build for grpc
FROM alpine:3.6 AS base
RUN apk add --no-cache python3 ca-certificates tzdata tini \
&& apk upgrade --no-cache
FROM base AS build
RUN apk add --no-cache \
python3-dev \
cython \
build-base
import tensorflow as tf
from scipy.special import logit
def centering_inference(c):
"""
:param c: the number of target classes
:return: a uniformly distributed class bias variable
"""
return tf.Variable(
@NathanHowell
NathanHowell / curry.hs
Created May 31, 2013 23:36
A proof-of-concept demonstrating the use of Z3 to solve Cabal version constraints for Haskell packages
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
@NathanHowell
NathanHowell / stack.yaml
Created February 3, 2016 06:28
GHC 8.0 release candidate stack/stackage yaml
resolver: ghc-8.0.0.20160111
setup-info:
ghc:
linux64:
8.0.0.20160111:
url: "http://downloads.haskell.org/~ghc/8.0.1-rc1/ghc-8.0.0.20160111-x86_64-deb7-linux.tar.xz"
content-length: 111404852
sha1: 30d39c6ca6994dcafe25595e053035ad23198b52
macosx:
8.0.0.20160111:
instance (a ~ Proxy "Sum types are not supported by LLVM") => GGetElementIndex a (x :+: y) where
type GGetElementPtrType a (x :+: y) = Void
ggetElementIndex _ _ = error "Sum types are not supported by LLVM"
type family StructElement (a :: [*]) (n :: Nat) :: * where
StructElement (x ': xs) 0 = x
StructElement (x ': xs) n = StructElement xs (n - 1)
StructElement '[] n = Proxy "Attempting to index past end of structure"
@NathanHowell
NathanHowell / 1.idr
Last active March 23, 2016 14:57
A port of `Fin` and `natToFin` from Idris to Haskell.
module Data.Fin
%default total
%access public export
||| Numbers strictly less than some bound. The name comes from "finite sets".
|||
||| It's probably not a good idea to use `Fin` for arithmetic, and they will be
||| exceedingly inefficient at run time.
||| @ n the upper bound
@NathanHowell
NathanHowell / error.txt
Last active January 1, 2016 11:38
GNTD regressions in GHC HEAD. This typechecks on 7.6.3 but not on 7.7.20131217 unless ImpredicativeTypes are enabled.
[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 October 8, 2013 07:30
Convert a type to a nested tuple, preserving left-to-right ordering via CPS conversion.
{-# 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
.cabal-sandbox/
dist/
cabal.config
cabal.sandbox.config
.*.swp