Skip to content

Instantly share code, notes, and snippets.

View adamwespiser's full-sized avatar

Adam Wespiser adamwespiser

View GitHub Profile
@adamwespiser
adamwespiser / joshua.py
Last active October 16, 2023 03:08
A basic python script that plays a human player in a game of tic tac toe
#!/usr/bin/python
# Copyright Adam Wespiser, 2012
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@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
@adamwespiser
adamwespiser / gitGuide.md
Last active March 2, 2023 18:59
some helpful commands
@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
{- 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 / 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)
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)