Skip to content

Instantly share code, notes, and snippets.

View bitemyapp's full-sized avatar
🐺
aroo

Chris A. bitemyapp

🐺
aroo
View GitHub Profile
@bitemyapp
bitemyapp / foo.hs
Created April 22, 2016 04:32 — forked from jtobin/foo.hs
Independence and Applicativeness
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE LambdaCase #-}
import Control.Applicative.Free
import Control.Monad
import Control.Monad.Free
import Control.Monad.Primitive
import System.Random.MWC.Probability (Prob)
import qualified System.Random.MWC.Probability as MWC
module-template: ! 'module MODULE_NAME where
'
extensions: {}
environment: default
cabal-file: project.cabal
version: 1
ghc-args: []
excluded-modules: []
@bitemyapp
bitemyapp / redis-yesod.md
Created February 29, 2016 22:23 — forked from MaxGabriel/redis-yesod.md
Connecting to Redis from Yesod

Connecting to Redis from Yesod

This is a quick run-through of how I connected to Redis from a Yesod site (which used the default scaffolding). There isn't much specific to Redis here, so this information should apply to connecting to any database or service from Yesod.

Background: Basics of Hedis

First, a brief intro of the basics of Hedis:

{-# LANGUAGE OverloadedStrings #-}
@bitemyapp
bitemyapp / haskell-mode-indent.md
Created February 15, 2016 23:06 — forked from ttuegel/haskell-mode-indent.md
Indentation pains in haskell-mode for Emacs

Electric indentation for parentheses, brackets, braces, commas, semicolons...

This isn't an issue of what I want, but rather when I want it. haskell-mode knows how to indent these things correctly, but I had to turn off electric indentation in haskell-mode because it does stupid things the rest of the time.

Concretely, I want a haskell-mode that knows how to be electric when there's only one "right" choice and that doesn't do stupid things when there are multiple possibilities.

@bitemyapp
bitemyapp / binary.hs
Created February 3, 2016 08:58 — forked from sinelaw/binary.hs
Binary encode/decode of Fixed
-- run it like:
-- stack ghc --package criterion -- binary.hs -Wall -O2 && ./binary
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE BangPatterns #-}
module Main where
import Data.ByteString.Lazy (ByteString)
import Data.Binary
import Data.Fixed
@bitemyapp
bitemyapp / Categories.hs
Created January 29, 2016 23:09 — forked from ekmett/Categories.hs
UndecidableSuperClasses test case
{-# language KindSignatures #-}
{-# language PolyKinds #-}
{-# language DataKinds #-}
{-# language TypeFamilies #-}
{-# language RankNTypes #-}
{-# language NoImplicitPrelude #-}
{-# language FlexibleContexts #-}
{-# language MultiParamTypeClasses #-}
{-# language GADTs #-}
{-# language ConstraintKinds #-}
@bitemyapp
bitemyapp / semantickata.hs
Created January 20, 2016 01:26 — forked from raichoo/semantickata.hs
Mini programming language to implement the recursive `fact` function.
{-# LANGUAGE LambdaCase #-}
module Main where
import Control.Applicative (liftA2)
import Control.Monad.Reader
type Varname = String
type Env = [(Varname, Dom)]
data Dom
@bitemyapp
bitemyapp / Grammar.hs
Created December 12, 2015 07:44 — forked from frasertweedale/Grammar.hs
Prism-based parser/printer experiment
-- This file is a parsing experiment
-- Copyright (C) 2015 Fraser Tweedale
--
-- This software is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero 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
@bitemyapp
bitemyapp / moments_nuke.css
Created December 5, 2015 00:11
Put this in a Stylish mod for your Twitter on your browser to nuke the Moments button
// https://twitter.com/bitemyapp/status/672930049830596608
a[data-nav=moments] {
display: none !important;
}
@bitemyapp
bitemyapp / organize.hs
Created December 2, 2015 04:58 — forked from noprompt/organize.hs
My first Haskell script (organizes files in a directory by extension)
module Main where
import qualified System.Directory as Directory
import qualified System.FilePath as FilePath
import Control.Monad (forM, forM_, liftM)
import qualified Data.HashMap.Strict as HashMap
import Text.Printf (printf)
isFile :: FilePath -> IO Bool
isFile = Directory.doesFileExist