Skip to content

Instantly share code, notes, and snippets.

@imeckler
imeckler / BFS.hs
Last active October 12, 2017 01:55
BFS
{-# LANGUAGE LambdaCase #-}
import Control.Applicative
import Control.Monad.State
import System.Random
data Tree a = Empty | Bin a (Tree a) (Tree a)
deriving Show
-- O(n)
@pyrtsa
pyrtsa / gist:6213784
Created August 12, 2013 18:46
When installing Haskell Platform fails on Mac OS X (with quick fix below)

When installing Haskell Platform fails on Mac OS X (with quick fix below)

I was fighting with Haskell last weekend. At first, I couldn't install some missing libraries with Cabal, and then, when trying to find out what's wrong, I ended up removing the whole Haskell installation — only to find out I could no longer install neither the Haskell Platform nor even just Cabal Install! The warnings I would see were more or less about the use of the single quote in source code:

Preprocessing library text-0.11.2.3...

Data/Text.hs:6:52:
     warning: missing terminating ' character [-Winvalid-pp-token]

-- Copyright : (c) 2009, 2010, 2011, 2012 Bryan O'Sullivan,

@i-e-b
i-e-b / Readme_NIX_OS.md
Last active July 4, 2023 16:53
/etc/nixos/configuration.nix

My experiments with an XMonad setup in NixOS. This is my work box now, so it pretty much works.

probably needs:

# useradd -m iain
# passwd iain ...
# passwd root ...
@nikita-volkov
nikita-volkov / gist:6977841
Last active July 4, 2022 13:33
Anonymous records. A solution to the problems of record-system.

#Anonymous records. A solution to the problems of record-system.

Please, beware that the proposal that follows has been implemented as a library.

The current record system is notorious for three major flaws:

  1. It does not solve the namespacing problem. I.e., you cannot have two records sharing field names in a single module. E.g., the following won't compile:

data A = A { field :: String }

@wsargent
wsargent / docker_cheat.md
Last active August 31, 2023 12:10
Docker cheat sheet
@cartazio
cartazio / xcode5-haskell-directions.md
Last active May 28, 2019 00:35
xcode 5 + OS X 10.9 mavericks GHC work around nuttiness

PSA :

just use GHC for OSX https://ghcformacosx.github.io

the rest of these directions are preserved for historical purposes

TLDR version, if you have homebrew

xcode-select --install ; brew tap homebrew/versions ;   brew tap homebrew/dupes \
@timmytofu
timmytofu / ghcPkgUtils.sh
Last active June 6, 2020 12:02 — forked from simonmichael/gist:1185421
ghc-pkg-clean and ghc-pkg-reset compatible with both zsh and bash
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
do
echo unregistering $p; ghc-pkg $* unregister $p
done
}
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.
@co-dan
co-dan / .zshrc
Last active December 31, 2015 08:49
Cabal sandbox status in your ZSH prompt
#
# This simple script displays whether you are in a cabal sandbox
# the the result of checking for a sandbox is cached, but now that I
# actually think about it, it was probably an unnecessary step.
# Don't forget to customize the PROMPT variable at the bottom
#
# Looks like this with my prompt: https://files.app.net/rjphjAG9.png
#
function update_cabal_sandbox_info () {
@Justasic
Justasic / ThreadEngine.cpp
Last active October 20, 2017 10:19
A dynamic threading engine I built for a game I never made. You should only interact with the ThreadHandler class. Requires C++14 or C++17.
/*
* Copyright (c) 2013-2017, Justin Crawford <Justin@stacksmash.net>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose
* with or without fee is hereby granted, provided that the above copyright notice
* and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL