Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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
#!/bin/sh
#
# Recipe for reproducing a linkage error with GHC 7.8.3 under OSX.
#
# GHC was installed using https://ghcformacosx.github.io/
#
# Specific 7.8.3 version: https://github.com/ghcformacosx/ghc-dot-app/releases/download/v7.8.3-r1/ghc-7.8.3-r1.zip
#
# Output of the find command at the end will include a reference to 'findExecutable3_info',
# but nowhere does the tar package reference the function 'findExecutable'.
@erantapaa
erantapaa / cabal.config
Created February 2, 2015 20:10
hackage versions as of 2012-05-23 UTC
-- Hackage versions as of 2012-05-23 00:00:00 UTC
constraints:
4Blocks <= 0.2,
AC-Angle <= 1.0,
AC-Boolean <= 1.1.0,
AC-BuildPlatform <= 1.1.0,
AC-Colour <= 1.1.4,
AC-EasyRaster-GTK <= 1.1.3,
AC-HalfInteger <= 1.2.1,
AC-MiniTest <= 1.1.1,
@erantapaa
erantapaa / example.hs
Created January 27, 2015 18:14
embed svg diagram in html using blaze
{-# LANGUAGE OverloadedStrings #-}
import Text.Blaze.Svg11 ((!), mkPath, rotate, l, m)
import qualified Text.Blaze.Svg11 as S
import qualified Text.Blaze.Svg11.Attributes as A
import Text.Blaze.Svg.Renderer.String (renderSvg)
import qualified Text.Blaze.Html5 as H
import Text.Blaze.Html.Renderer.Text
import qualified Data.Text.Lazy.IO as TL
main :: IO ()
@erantapaa
erantapaa / nested.x
Created January 26, 2015 02:09
alex nested comment example
{
module Nested where
import Control.Monad
}
%wrapper "monadUserState"
$whitespace = [\ \t\b]
$digit = 0-9 -- digits
@erantapaa
erantapaa / gauss.hs
Created January 17, 2015 03:47
solution to 1had "Let it snow" http://lpaste.net/118571
-- Solution to "Let it snow" 1had - http://lpaste.net/118571
import qualified Data.Map.Strict as M
import Data.List
import Control.Monad
import Data.Maybe
data SnowFlake = Six | Star | Eight | Flower | Unit
deriving (Eq, Ord, Show)