Skip to content

Instantly share code, notes, and snippets.

@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-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 / 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 / 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 / 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 / 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 / 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 / start_pbj_sc.sh
Created August 18, 2018 15:45
Start SuperCollider script from the Pisound button
#!/bin/sh
. /usr/local/pisound/scripts/common/common.sh
log "starting pbj"
flash_leds 1
killall scsynth
killall sclang
rm -f /tmp/sclang-*.log 2>/dev/null || true
@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.
@mzero
mzero / flash-test.ino
Created July 7, 2020 21:27
Feather Express flash tester
#include <Adafruit_SPIFlash.h>
namespace {
// ===
// === Test Data Generation and Checking
// ===
const size_t BLOCKSIZE = 512;