Skip to content

Instantly share code, notes, and snippets.

View isovector's full-sized avatar

Sandy Maguire isovector

View GitHub Profile
@jasonreich
jasonreich / List.hs
Created December 27, 2010 13:30
List append associativity proof in Haskell's type system... perhaps
{-
Uses the She (Stathclyde Haskell Enhancement), which you
can get from http://bit.ly/gaVM8X.
-}
{-# OPTIONS_GHC -Wall -F -pgmF she #-}
{-# LANGUAGE GADTs, KindSignatures #-}
{-# LANGUAGE TypeFamilies, TypeOperators #-}
{-# LANGUAGE RankNTypes, FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
@zdavkeos
zdavkeos / walk_up.py
Created July 21, 2011 23:18
python walk_up - like os.walk, only works its way up instead of down
#!/bin/env python
"""
os.walk is an awesome generator.
However, I needed the same functionality,
only I wanted to walk 'up' the
directory tree.
This allows seaching for files
in directories directly above
@yantonov
yantonov / install-ghc-ubuntu.md
Last active June 11, 2020 09:20
How to install latest GHC from source + latest stack + cabal + cabal-install on ubuntu

How to install GHC from source + latest stack + cabal + cabal-install on ubuntu

for your convinience this instuction is available as:
gist
git repo

preferred way install stack than install ghc

stack (package manager and build tool, preferrered way to manage dependencies)

# settings
import System.Directory
import System.Environment
import System.FilePath
import Control.Applicative ((<$>))
import Control.Arrow (first, second)
import Control.Monad (void)
import Data.Either (rights)
import Data.List (isSuffixOf)
import Data.Set (Set, (\\), empty, fromList, insert, singleton, toList, union)
import Text.Parsec
@zhenyanghua
zhenyanghua / code.gs
Created July 15, 2014 19:55
Googlemaps + Google Sheets + Google Forms
var SPREADSHEET_ID='Google Sheets ID';
var SHEET_NAME = 'Google Sheets Table Name';
function doGet(request) {
var callback = request.parameters.jsonp;
var range = SpreadsheetApp.openById(SPREADSHEET_ID).getSheetByName(SHEET_NAME).getDataRange();
var json = callback+'('+Utilities.jsonStringify(range.getValues())+')';
return ContentService.createTextOutput(json).setMimeType(ContentService.MimeType.JAVASCRIPT);
}
@malcolmocean
malcolmocean / geoff-yed-tips
Created April 19, 2015 05:40
Geoff's tips for setting up yEd
From Geoff Anders, of Leverage Research (http://www.leverageresearch.org/)
For people doing goal factoring - or for people making any sort of box-and-arrow diagram - I recommended the program yEd. It is available here: http://www.yworks.com/en/products_yed_about.html
After you install it, I highly recommend setting up the defaults in the following way:
1. Open yEd.
2. Create a new document.
3. Click the white background; a small yellow square should appear on the canvas.
4. Click the small yellow square so as to select it.
@chpatrick
chpatrick / Bake.hs
Last active September 15, 2018 04:20
Baked-in Storable Vectors Mark II
{-# LANGUAGE MagicHash, TupleSections, TemplateHaskell #-}
module Data.Vector.Storable.Bake(bake, unsafeFromAddrLen) where
import Data.Typeable
import qualified Data.Vector.Storable as VS
import Foreign
import GHC.Prim
import GHC.Ptr
import Language.Haskell.TH
@mtolly
mtolly / Adder.hs
Created July 29, 2015 01:22
Small example of compiling a Haskell Mac .dylib to be used from C
{-# LANGUAGE ForeignFunctionInterface #-}
module Adder where
import Foreign.C
adder :: CInt -> CInt -> IO CInt
adder x y = return $ x + y
foreign export ccall adder :: CInt -> CInt -> IO CInt
@PkmX
PkmX / loeb.md
Last active January 9, 2019 15:59
Löb with error handling

Löb with error handling

löb is a well-known function in Haskell for implementing spreadsheet-like behaviors and tying the knot. It is defined as:

loeb :: Functor f => f (f a -> a) -> f a
loeb fs = xs
  where xs = fmap ($ xs) fs
@parsonsmatt
parsonsmatt / mtl.hs
Last active October 27, 2017 23:20
`mtl` style enables reinterpretation of a monad, like `free`
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleContexts #-}
module Mtl where
import Control.Monad.State
import Control.Monad.Except
runMtl
:: Bool