Skip to content

Instantly share code, notes, and snippets.

avalonalex / Cons.hs
Last active Sep 17, 2015
Cons.hs show function representation of pairs and positive integers in Haskell.
View Cons.hs
{-# LANGUAGE RankNTypes #-}
-- | Laws:
-- > car (ChurchTuple a b) == a
-- > cdr (ChurchTuple a b) == b
newtype ChurchTuple a b = ChurchTuple { unChurchTuple :: forall c. ((a -> b -> c) -> c) }
churchTuple :: a -> b -> ChurchTuple a b
churchTuple a b = ChurchTuple $ \m -> m a b
View .ghci
:set prompt ">>> "
import Control.Applicative
import Control.Monad
import Data.ByteString (ByteString)
import Data.HashMap.Strict (HashMap)
import Data.Map (Map)
import Data.Set (Set)
import Data.Text (Text)
import qualified Data.ByteString as B
avalonalex / gist:c5a378fa1af9820da57c
Created Apr 21, 2015
uninstall haskell platform
View gist:c5a378fa1af9820da57c
sudo rm -rf /Library/Frameworks/GHC.framework
sudo rm -rf /Library/Frameworks/HaskellPlatform.framework
sudo rm -rf /Library/Haskell
rm -rf .cabal
rm -rf .ghc
rm -rf ~/Library/Haskell
find /usr/bin /usr/local/bin -type l | \
xargs -If sh -c '/bin/echo -n f /; readlink f' | \
egrep '//Library/(Haskell|Frameworks/(GHC|HaskellPlatform).framework)' | \
cut -f 1 -d ' ' > /tmp/hs-bin-links
View mac-switch-meta.el
;; Keybonds
(global-set-key [(hyper a)] 'mark-whole-buffer)
(global-set-key [(hyper v)] 'yank)
(global-set-key [(hyper c)] 'kill-ring-save)
(global-set-key [(hyper s)] 'save-buffer)
(global-set-key [(hyper l)] 'goto-line)
(global-set-key [(hyper w)]
(lambda () (interactive) (delete-window)))
(global-set-key [(hyper z)] 'undo)
avalonalex / ParserMonad.hs
Created Jun 30, 2014
a simple parser monad
View ParserMonad.hs
{-# OPTIONS -Wall -fwarn-tabs -fno-warn-type-defaults #-}
-- The basic definition of the parsing monad.
module Parser (Parser,
View install consolas on mac
# Thanks to this post:
$ brew install cabextract
$ cd ~/Downloads
$ mkdir consolas
$ cd consolas
$ curl -O
$ cabextract PowerPointViewer.exe
$ cabextract
avalonalex / Zip.hs
Last active Mar 6, 2018
An implementation of List Zip for moving `cursor` back and forth through list.
View Zip.hs
{-# OPTIONS -Wall -Werror -fwarn-tabs -fno-warn-type-defaults #-}
module Zip where
newtype Zip a = Z ([a], [a]) deriving Show
mkZip :: [a] -> Zip a
mkZip l = Z ([], l)
current :: Zip a -> a
avalonalex /
Last active Mar 6, 2021
A implementation of RSA public key encryption algorithms in python, this implementation is for educational purpose, and is not intended for real world use. Hope any one want to do computation like (a^b mode n) effectively find it useful.
#!/usr/bin/env python
import argparse
import copy
import math
import pickle
import random
from itertools import combinations