Skip to content

Instantly share code, notes, and snippets.

View mbrcknl's full-sized avatar
🕸️
catching bugs

Matthew Brecknell mbrcknl

🕸️
catching bugs
View GitHub Profile
@mbrcknl
mbrcknl / Hedge.hs
Last active August 29, 2015 14:06
-- Is Set.union better than O(n+m) in some cases?
import Criterion.Main (Benchmark, bench, bgroup, defaultMain, env, whnf)
import Data.Set (Set, fromList, union)
main :: IO ()
main = defaultMain [ bgroup "union" $ map benchUnion sizes ]
-- Grow Set size exponentially, under the hypothesis that
-- Set.union will be O(log n) in this special case.

Learning about trampolining in Scala.

I began with Ken Scambler's [YOW! Lambda Jam 2014 workshop][ws] on Free monads, but found that the simple formulation of Free derived in [exercise 1][ex1] was susceptible to stack overflow when used for trampolining in [exercise 2][ex2]. This is just an investigation into what causes this stack overflow, and how [scalaz][]'s [GoSub][] trick avoids it.

Initial call

bounce(append(List(1,2,3,4,5),List(6)))

Descend into argument

append(List(1,2,3,4,5),List(6))
bounce(...)
import Data.Set.Monad as SM
import Debug.Trace as DT
(<+>) = liftM . plus
plus x y = DT.trace "." (x + y)
l = SM.fromList [0,1]
-- Intuitively expect 28 additions, but we actually get 60!
test = Set Int
@mbrcknl
mbrcknl / .profile
Created March 23, 2013 09:06
How I start gpg-agent on login to OS X. I use Macports gnupg2, with pinentry +qt4, though with a suitable adjustment to the PATH, this should work if you get your gnupg from somewhere else.
# ...
if [ -f ~/.gpg-agent-info ]; then
. ~/.gpg-agent-info
export GPG_AGENT_INFO
fi
# ...
@mbrcknl
mbrcknl / .gvimrc
Created February 27, 2013 07:55
Vim config I used for screencast http://brck.nl/hole-driven-haskell
" Disable cursor blink so I can freely cut, splice and vary the speed of the screencast.
set guicursor+=a:blinkon0
" Get rid of toolbar and scrollbars.
set guioptions-=T
set guioptions-=L
set guioptions-=r
set background=dark