Skip to content

Instantly share code, notes, and snippets.

View sdiehl's full-sized avatar
💭
I may be slow to respond.

Stephen Diehl sdiehl

💭
I may be slow to respond.
View GitHub Profile
@sdiehl
sdiehl / gist:e5c9daab7a6d1da0ede7
Created December 18, 2014 12:53
GenApply.cmm
// DO NOT EDIT!
// Automatically generated by GenApply.hs
#include "Cmm.h"
#include "AutoApply.h"
INFO_TABLE_RET(stg_ap_v, RET_SMALL, W_ info_ptr, )
{
W_ info;
W_ arity;
@sdiehl
sdiehl / hackagedocs.sh
Created September 21, 2014 17:58
Manual Hackage docs update script
# Usage: sh hackagedocs.sh mypackage 0.1 UserName Password
cabal configure && cabal build && cabal haddock --hyperlink-source \
--html-location='http://hackage.haskell.org/package/$pkg/docs' \
--contents-location='http://hackage.haskell.org/package/$pkg'
S=$?
if [ "${S}" -eq "0" ]; then
cd "dist/doc/html"
DDIR="${1}-${2}-docs"
cp -r "${1}" "${DDIR}" && tar -c -v -z --format ustar -f "${DDIR}.tar.gz" "${DDIR}"
@sdiehl
sdiehl / io_imp.hs
Created August 1, 2014 20:41
io_impl.hs
instance Monad IO where
{-# INLINE return #-}
{-# INLINE (>>) #-}
{-# INLINE (>>=) #-}
m >> k = m >>= \ _ -> k
return = returnIO
(>>=) = bindIO
fail s = failIO s
returnIO :: a -> IO a
@sdiehl
sdiehl / preamble.hs
Last active February 1, 2016 20:16
Modern Haskell Preamble
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
-------------------------------------------------------------------------------
-- BEGIN PRELUDE --------------------------------------------------------------
-------------------------------------------------------------------------------
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
{-# LANGUAGE OverlappingInstances #-}
undefined = undefined
@sdiehl
sdiehl / chapter7.c
Last active January 2, 2016 21:59
Comparison for jamwt example
// clang -O3 -S -emit-llvm chapter7.c -o -
// clang -O3 -S chapter7.c -o -
#include <inttypes.h>
#include <stdio.h>
double fib(double x) {
return x < 3 ? 1 : fib(x-1) + fib(x-2);
}
thinkpad% ghc -v -static -optl-pthread OpenBLAS/libopenblas.a src/Numerical/OpenBLAS/FFI.hs Test.hs
Glasgow Haskell Compiler, Version 7.6.3, stage 2 booted by GHC version 7.6.2
Using binary package database: /usr/lib/ghc-7.6.3/package.conf.d/package.cache
Using binary package database: /home/stephen/.ghc/x86_64-linux-7.6.3/package.conf.d/package.cache
hiding package binary-0.5.1.1 to avoid conflict with later version binary-0.7.1.0
hiding package Cabal-1.16.0 to avoid conflict with later version Cabal-1.18.1.2
hiding package hashtables-1.0.1.8 to avoid conflict with later version hashtables-1.1.0.2
hiding package hmatrix-0.14.1.0 to avoid conflict with later version hmatrix-0.15.0.1
hiding package case-insensitive-1.0.0.2 to avoid conflict with later version case-insensitive-1.1
hiding package reducers-3.0.2 to avoid conflict with later version reducers-3.0.2.1
#include <Python.h>
/*
* Usage
$ python
Python 2.7.3 |Anaconda 1.4.0 (64-bit)| (default, Feb 25 2013, 18:46:31)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import evil
x(t) = ((-2/3 sin(11/7-8 t)+257/6 sin(t+11/7)+28/5 sin(2 t+11/7)+40/7 sin(3 t+11/7)+15/4 sin(4 t+8/5)+11/6 sin(5 t+8/5)+2/3 sin(6 t+33/7)+2/5 sin(7 t+8/5)+25/24 sin(9 t+11/7)+1/2 sin(10 t+11/7)-254/3) theta(131 pi-t) theta(t-127 pi)+(-41/4 sin(11/7-2 t)+834/5 sin(t+11/7)+138/5 sin(3 t+11/7)+7/6 sin(4 t+10/7)+63/4 sin(5 t+11/7)+3/2 sin(6 t+11/7)+81/8 sin(7 t+14/3)+127/5 sin(8 t+33/7)+9 sin(9 t+14/3)+5/2 sin(10 t+8/5)+7/8 sin(11 t+14/9)+11/4 sin(12 t+33/7)+4/5 sin(13 t+8/5)+65/11 sin(14 t+33/7)+20/7 sin(15 t+14/3)+12/7 sin(16 t+14/3)+31/10 sin(17 t+8/5)+1390/3) theta(127 pi-t) theta(t-123 pi)+(-130/3 sin(11/7-t)+52/7 sin(2 t+8/5)+421/6) theta(123 pi-t) theta(t-119 pi)+(-53/18 sin(11/7-3 t)-139/6 sin(11/7-t)+43/5 sin(2 t+8/5)+16/7 sin(4 t+11/7)+3/4 sin(5 t+33/7)+2/3 sin(6 t+11/7)+2/3 sin(7 t+33/7)+3/5 sin(8 t+11/7)+1/3 sin(9 t+33/7)+1/2 sin(10 t+8/5)+3859/10) theta(119 pi-t) theta(t-115 pi)+(433/3 sin(t+8/5)+25/7 sin(2 t+8/5)+107/7 sin(3 t+8/5)+3/7 sin(4 t+13/7)+12/5) theta(115 pi-t) theta(t-111 pi)+(-61/7 sin(1
{-# Language GADTs #-}
module Homomorphisms where
import Control.Monad
import Control.Applicative
import Data.Monoid hiding (Endo)
import qualified Control.Category as C