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 / 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
@bitemyapp
bitemyapp / leaf.hs
Created November 24, 2015 23:24 — forked from ali-abrar/index.html
Setting up Leaflet.js with Reflex.Dom
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
import Reflex.Dom
import Data.Monoid
import GHCJS.Types
import GHCJS.Foreign
import GHCJS.DOM.Element
import GHCJS.DOM.Types
import Control.Monad.IO.Class
newtype LeafletMap = LeafletMap { unLeafletMap :: JSRef LeafletMap }
@bitemyapp
bitemyapp / dpll.hs
Created November 11, 2015 18:33 — forked from parsonsmatt/dpll.hs
{-
DPLL from the textbook:
function DPLL(clauses, symbols, model ) returns true or false
if every clause in clauses is true in model then return true
if some clause in clauses is false in model then return false
P , value ← FIND-PURE-SYMBOL (symbols, clauses, model )
if P is non-null then return DPLL(clauses, symbols – P , model ∪ {P =value})
P, value ← FIND-UNIT-CLAUSE (clauses, model)
if P is non-null then return DPLL(clauses, symbols – P , model ∪ {P =value})
@bitemyapp
bitemyapp / AverageByConduit.hs
Created November 6, 2015 03:30 — forked from erewok/Main.hs
Moving Average Test: Uses Haskell Conduits
module Main where
import Control.Applicative ((<$>), (<*>))
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.State (StateT)
import Data.Conduit (($$), (=$=), (=$)
, Conduit, Sink, Source
, await, yield)
import qualified Data.Conduit.List as CL
import qualified Data.Vector.Unboxed as V
  1. Don't use partial functions (head, read, tail, fromJust, fail (in IO), error, undefined ... )
  2. Functions are your friend, use lots of them and keep them small.
  3. Serialization errors are the most common error in our codebase. When you are creating a JSON, Binary or Serialize instance try and avoid the standard "generator" functions.
@bitemyapp
bitemyapp / Codensity.idr
Last active September 11, 2015 20:48 — forked from raichoo/Codensity.idr
List Codensity transformation in Idris
module Main
data Free : (f : Type -> Type) -> (a : Type) -> Type where
Pure : a -> Free f a
Bind : f (Free f a) -> Free f a
instance Functor f => Functor (Free f) where
map f (Pure x) = Pure (f x)
map f (Bind x) = assert_total (Bind (map (map f) x))