Skip to content

Instantly share code, notes, and snippets.

@mzero
mzero / ghc-hp-docker-build.md
Last active August 29, 2015 14:22
Building GHC & HP hermetically using Docker

Building on the NUC under Docker

[hs-base] - a Debian 7 (Wheezy) base environment

[debian:7] + build dev-docker/hs-base/Dockerfile --> [hs-base]

[ghc-boot]

  • an environment with a bootstrap GHC
@mzero
mzero / info.md
Created July 20, 2014 17:33
Root cause of haddock / clang failure

Root cause of haddock / clang failure

Consider this simple .hs file:

module MinHaddockFail where

yo :: String
yo = "yo"
@mzero
mzero / ghc-clang-wrapper
Created October 31, 2013 06:53
This wrapper script *should* enable GHC 7.* to work on systems with Xcode 5. To use it, drop this script somewhere, make it executable, and run.... Then follow the instructions it prints out. What it will do is, instruction you to put a copy in /usr/bin, then re-run it sudo. It will then find all your GHC 7 settings files, and patch them to make…
#!/bin/sh
inPreprocessorMode () {
hasE=0
hasU=0
hasT=0
for arg in "$@"
do
if [ 'x-E' = "x$arg" ]; then hasE=1; fi
if [ 'x-undef' = "x$arg" ]; then hasU=1; fi
@mzero
mzero / SequsHorribilis.hs
Created May 11, 2013 05:38
Implementation of 4Clojure problem #112 in Haskell See: http://www.4clojure.com/problem/112
module SequsHorribilis
where
import Test.HUnit
type Sequs = [Horribilis]
data Horribilis = Atom Int | List Sequs
deriving (Eq, Show)
upThru :: Int -> Sequs -> Sequs
@mzero
mzero / Posix.IO.hs
Created February 15, 2013 15:28
This is what the files look like split, but with the instance still with the typeclass
{-
Copyright 2012-2013 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@mzero
mzero / set.hs
Last active December 10, 2015 18:08 — forked from mscurtescu/set.hs
module SetPrime where
-- import qualified Data. as List
-- no need to import List, as the function all is in the Prelude
import Control.Applicative ((<$>), (<*>))
-- prefer explicit imports most of the time
data Shape = Oval | Squiggle | Diamond deriving (Show, Eq, Bounded, Enum, Ord)
data Color = Red | Purple | Green deriving (Show, Eq, Bounded, Enum, Ord)
@mzero
mzero / Triangle.hs
Created September 16, 2012 06:53
minimum path value through a triangle
module Triangle where
-- top-down version
minTriangleFlow :: (Num a, Ord a) => [[a]] -> a
minTriangleFlow = minimum . foldl sift []
where sift as bs = zipWith (+) bs $ pres as
pres [] = [0]
pres as@(ah:at) = ah : zipWith min as at ++ [last as]
-- bottom-up version (not safe if triangle input is misformed)
@mzero
mzero / Ant.hs
Created November 23, 2011 08:11
monadic ants
module Ant
where
import Prelude hiding (log)
import Control.Monad ((>=>))
import Data.List ((\\))
-- | A Simple logging Monad that logs items of type e
@mzero
mzero / UninstallHS.hs
Created November 21, 2011 02:04
Mac OS X Haskell Uninstaller preview
#!/usr/bin/env runghc
module Main where
{-
Uninstall.hs - a Haskell uninstaller for Mac OS X
This program is really far too big to be in a single file. However, I
wanted it to be easily distributable and runnable, and so have kept it all
together.