Skip to content

Instantly share code, notes, and snippets.

View adamwespiser's full-sized avatar

Adam Wespiser adamwespiser

View GitHub Profile
@adamwespiser
adamwespiser / ghcid-session.sh
Created May 8, 2021 05:38
Drops you into a tmux session with two windows, one window editing a skeleton Haskell module, the the other one a ghcid session with the module loaded
#!/bin/bash
set -e
if [ $# -eq 0 ]
then
echo "No arguments supplied"
exit 1;
fi
@adamwespiser
adamwespiser / RandomExample.hs
Last active February 11, 2021 06:58
Random Integers from Cryptonite
{- stack --resolver lts-16.8 --install-ghc exec ghci --package "random cryptonite text memory"-}
{- ghcid -c "stack RandomExample.hs" -}
{-# Language OverloadedStrings, PackageImports, ScopedTypeVariables, TypeApplications #-}
module RandomExample where
import Prelude
import qualified GHC.List as Fold
import "cryptonite" Crypto.Random (MonadRandom, drgNew, withDRG, getRandomBytes)
{- stack --resolver lts-16.8 --install-ghc exec ghci --package "protolude text binary" -}
{-# LANGUAGE DeriveGeneric, DuplicateRecordFields, ExistentialQuantification, FlexibleContexts, RankNTypes, ScopedTypeVariables, StandaloneDeriving #-}
{- ghcid -c "stack X.hs" -}
module Existenial where
import Data.Text
import Data.Binary
import GHC.Generics
@adamwespiser
adamwespiser / FSM.hs
Created August 10, 2020 04:47
Finite State Machine ~ in Haskell
{- stack
--resolver lts-16.8
--packages "transformers"
exec ghci
-}
{-# Language
EmptyDataDeriving
, GADTs
, GeneralizedNewtypeDeriving
tag: ghc-8.8.3-release
ghc is build with
$ ./hadrian/build.stack.sh --flavour=prof --configure -j binary-dist
but I'm just pointing to _build/stage1
stack is version 2.3.1
operating system is macos catalina
{- stack script
--resolver lts-14.20
-}
{-# Language RebindableSyntax
, ScopedTypeVariables
, FlexibleInstances
, NoMonomorphismRestriction
, OverloadedStrings
, InstanceSigs
@adamwespiser
adamwespiser / core-dump.hs
Last active January 21, 2020 02:48
Dive into core ghc 8.6 Conversion
{- stack script
--package "base mtl time ghc ghc-paths haskeline containers"
--resolver lts-14.20
-}
module Main where
-- Compiler
import GHC
import DynFlags
@adamwespiser
adamwespiser / .tmux.conf
Created January 6, 2020 02:46
Tmux Config + Session Script
# set auto-reload of this config
bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
# set default tmux bash version ... move to fish?
set -g default-shell /usr/local/bin/bash
# set colors to 256
set -g default-terminal "screen-256color" # colors!
# start with window 1 (instead of 0)
@adamwespiser
adamwespiser / updateSite.hs
Created December 18, 2019 12:45
Build script for blog, Haskell version
#!/usr/bin/env stack
{- stack script
--compile
--copy-bins
--resolver lts-14.17
--install-ghc
--package turtle
--package text
--package foldl
--package async
#!/bin/sh -e
alias firefox=/Applications/Firefox.app/Contents/MacOS/firefox
DIR="${XDG_CACHE_HOME:-$HOME/.cache}"
mkdir -p -- "$DIR"
TEMP="$(mktemp -d -- "$DIR/firefox-XXXXXX")"
trap "rm -rf -- '$TEMP'" INT TERM EXIT
firefox -profile "$TEMP" -no-remote "$@"