Skip to content

Instantly share code, notes, and snippets.

@erantapaa
erantapaa / hackage-server-build-notes
Last active August 29, 2015 14:14
building hackage-server
Currently hackage-server only builds with GHC 7.6.3.
# Installing ghc 7.6.3 for OSX
# download the GHC 7.6.3 tarball for OSX (64-bit)
# for links to other OSes: https://www.haskell.org/ghc/download_ghc_7_6_3
wget https://www.haskell.org/ghc/dist/7.6.3/ghc-7.6.3-x86_64-apple-darwin.tar.bz2
tar jxf ghc-7.6.3-x86_64-apple-darwin.tar.bz2
cd ghc-7.6.3
mkdir $HOME/apps
@erantapaa
erantapaa / schemers-monads.hs
Created May 27, 2015 15:50
Haskell version of "A Schemer's View of Monads"
module Foo where
-- This is a translation to Haskell of parts of the paper
-- "A Schemer's View of Monads" by Adam C. Foltzer & Daniel P. Friedman:
--
-- https://cgi.soic.indiana.edu/~c311/lib/exe/fetch.php?media=manymonads.pdf
import Control.Monad.State
-- `Tree a` is a way of describing only those S-exps which are trees
@erantapaa
erantapaa / hse-pprint.hs
Created May 28, 2015 05:17
pretty print the AST generated by Language.Haskell.Exts
{- Simple pretty printer for the AST created by Language.Haskell.Exts.
-
- Usage: program source.hs
-
-}
import qualified Language.Haskell.Exts as E
import Language.Haskell.Exts.Parser (ParseResult(..))
import Data.List
import System.Environment
@erantapaa
erantapaa / build-notes.md
Last active August 29, 2015 14:22
haskell.org site build notes

Some notes on building hl (the haskell.org website) on an Unbuntu box.

  1. Follow the instructions at https://www.stackage.org/install#ubuntu to install the GHC tool chain.

  2. Install the following packages:

    sudo apt-get install -y libicu-dev

  3. Run:

@erantapaa
erantapaa / annotate
Last active August 29, 2015 14:22
annotate - annotate output with time elapsed
#!/usr/bin/perl
use POSIX qw(strftime);
$| = 1;
sub annotate_handle {
my ($handle) = @_;
my $start = time();
while (<$handle>) {
@erantapaa
erantapaa / start-light
Created June 17, 2015 07:41
start a static web server with lighttpd
#!/usr/bin/env python
#
# Provision a static lighttpd server in $HOME/.lighttpd/config-<port>
import os
import re
import sys
from os.path import expanduser
CONF_TEMPLATE='''
@erantapaa
erantapaa / gist:4fe5baf90ba58bd0bcc5
Created July 2, 2015 06:18
Auto derive aeson ToJSON instance
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
module Lib
where
import Data.Aeson
import GHC.Generics (Generic)
import Data.Stringable
@erantapaa
erantapaa / rahkana-example.hs
Last active August 29, 2015 14:27
pipes server-client example
-- Example of using the Rakhana libraries.
-# LANGUAGE NoMonomorphismRestriction #-}
module Foo
where
import Data.Rakhana
import Control.Monad.Trans (liftIO)
import qualified Data.ByteString.Char8 as B
@erantapaa
erantapaa / setup-tuf.sh
Created August 27, 2015 15:27
Setting up keys for a new hsackage-server
#!/bin/sh
#
# Script to populate a TUF directory with a new set of private keys.
#
# Note: Need to install the hackage-repo-tool package from Hackage.
REPO_TOOL=hackage-repo-tool
KEYS_DIR=/tmp/keys
DATA_DIR=./datafiles
@erantapaa
erantapaa / build-new-haddock.md
Last active September 8, 2015 17:36
build new haddock instructions
  1. Download and build the newest haddock. The build instructions are in README.md.

    git clone https://github.com/haskell/haddock.git cd haddock

    cabal sandbox init cabal sandbox add-source haddock-library cabal sandbox add-source haddock-api cabal install --dependencies-only