Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
cabal configure && cabal build && cabal haddock --hyperlink-source \
--html-location='/package/$pkg-$version/docs' \
--contents-location='/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}"
CS=$?
@ttuegel
ttuegel / config.nix
Created June 2, 2014 19:07
Use packages from config.nix in shell.nix
pkgs:
{
packageOverrides = pkgs: with pkgs; rec {
hsDevTools = hsPkgs: [
hsPkgs.cabalInstall
hsPkgs.ghcMod
];
};
}
@ttuegel
ttuegel / config.nix
Created June 2, 2014 17:57
Override haskellPackages
{ pkgs }:
{
packageOverrides = self: rec {
haskellPackages_ghcHEAD = self.haskell.packages {
ghcPath = /home/shana/programming/ghc;
ghcBinary = self.haskellPackages.ghcPlain;
prefFun = self.haskell.ghcHEADPrefs;
extraArgs = {
happy = self.haskellPackages.happy_1_19_2;
@ttuegel
ttuegel / Tee.hs
Last active August 29, 2015 14:01
Strict implementation of `tee`
module Tee where
import Control.Concurrent (forkIO)
import Control.Exception (handle, throw)
import Control.Monad (forever, void)
import System.IO (Handle, hGetChar, hPutChar)
import System.IO.Error (isEOFError)
-- This implementation is actually worse than the lazy one! The lazy
-- implementation would lock up if all of the output handles became full;
@ttuegel
ttuegel / Unfold.hs
Last active August 29, 2015 14:00
Binding on unfoldr
module Data.Unfold where
import Control.Applicative
import Data.Foldable
import Data.Maybe (fromMaybe)
import Prelude hiding (foldl, foldr, repeat)
-- This is a useful abstraction that I haven't found on Hackage, but that
-- doesn't mean it's not there by some other name.
@ttuegel
ttuegel / gist:11263212
Last active August 29, 2015 14:00
Stupid array shape strawman
{-# LANGUAGE TypeOperators #-}
-- Ignore the names, these are just tuples, not type lists
data major :. minor = major :. minor -- Row major shapes
data minor .: major = minor .: major -- Col major shapes
class Shape sh where
type Index sh
index :: sh -> Index sh -> Int
inRange :: sh -> Index sh -> Bool