Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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
];
};
}
#!/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 / gist:374df60a067a254e375f
Created November 18, 2014 19:21
.Xresources or .Xdefaults settings for FreeType
Xft.dpi: 96
Xft.antialias: 1
Xft.rgba: rgb
Xft.hinting: 1
Xft.hintstyle: hintslight
Xft.lcdfilter: lcddefault
Xft.autohint: 0
@ttuegel
ttuegel / gist:9a3be681985fc5837a38
Created January 24, 2015 00:09
Function application versus evaluation
ghci> import Control.Monad (liftM)
ghci> :t liftM
liftM :: Monad m => (a1 -> r) -> m a1 -> m r
ghci> import Debug.Trace (trace)
ghci> liftM (\x -> trace "function applied" (x + 3)) [1 :: Int, 2, 3]
[function applied
4,function applied
5,function applied
6]
ghci> liftM (trace "function evaluated" (+ 3)) [1 :: Int, 2, 3]
{ stdenv, fetchFromGitHub, cmake
, wayland, pixman, libxkbcommon, udev, libinput
, libX11, libxcb, x11
, mesa #nvidia_x11
, dbus, systemd
}:
let srcs = {
wlc = fetchFromGitHub {
owner = "Cloudef";
@ttuegel
ttuegel / patchelf.nix
Created September 13, 2015 17:50
patchelf.nix
with (import <nixpkgs> {}).pkgs;
stdenv.mkDerivation rec {
name = "patchelf-0.9-pre";
src = fetchgit {
url = https://github.com/NixOS/patchelf.git;
rev = "63296c4e18381216f740670916608f9ef159672e";
sha256 = "b6b2b4891773ea9d36f1891082812a157b7a6097827594419fe4a4343aa403a1";
};