Skip to content

Instantly share code, notes, and snippets.

View queertypes's full-sized avatar

Allele Dev queertypes

  • Georgia, USA
View GitHub Profile
@queertypes
queertypes / Teletype.hs
Created April 28, 2016 03:32
This is a tiny example of using Free monads + improve.
{-# LANGUAGE FlexibleContexts, DeriveFunctor #-}
--------------------------------------------------------------------------------
-- It's no secret - Allele Dev enjoys writing Haskell
--
-- This is a tiny example of using Free monads + improve.
--------------------------------------------------------------------------------
module Control.Teletype where
import Control.Monad
import Control.Monad.Free
@queertypes
queertypes / Logging.hs
Created April 22, 2016 01:33
Simple, context-rich logging module in Haskell
module API.Logging (
-- * Initialize
mkLog,
-- * Context, Types
Context(..),
Method(..),
Log,
-- * Logging
@queertypes
queertypes / Why.java
Last active March 30, 2016 19:43
Comparing Java class definition styles
///////////////////////////////////////////////////////////
// shortest: immutable data container with public data //
///////////////////////////////////////////////////////////
public class Contact {
public final Name name;
public final Address address;
public final PhoneNumber phoneNumber;
public final Email email;
public Contact(Name n, Address a, PhoneNumber p, Email em) {
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
-- Findings: almost everything could be inferred
@queertypes
queertypes / Boop.hs
Created January 8, 2016 02:23
Typeclass Name Collision Example
module Boop where
class Bee a where
meep :: a -> a
class Boop a where
meep :: a -> Int -> a
data Cat
= FluffyCat
@queertypes
queertypes / music-info.sh
Last active November 20, 2015 23:07
Bash: Music Info via Mediainfo
#!/bin/bash
function get {
local srcfile="$1"
local field="$2"
mediainfo "$srcfile" | grep "$field" | head -n 1 | cut -d: -f 2 | xargs
}
title=$(get "$1" 'Track name ')
album=$(get "$1" 'Album')
@queertypes
queertypes / TicTacToe.hs
Created November 2, 2015 02:49
A simple, terminal TicTacToe game written in Haskell
module TicTacToe (
run
) where
import Data.Array
import Data.Monoid
--------------------------------------------------------------------------------
-- Run the Game --
--------------------------------------------------------------------------------
@queertypes
queertypes / pinned.tweets
Created October 14, 2015 18:29
Pinned Tweets Archive???
* Beauty of abstraction: https://twitter.com/queertypes/status/489135228334931968
* Gay for type systems and girls: https://twitter.com/queertypes/status/654351932253978625
@queertypes
queertypes / Partial.hs
Created September 20, 2015 09:19
Partial Success Data Type
module PartialSuccess where
import Control.Applicative
import Control.Monad
import Data.Either (lefts, rights)
import Data.Monoid hiding (All)
--------------------------------------------------------------------------------
-- Partial: a data type for tracking success and failure --
--------------------------------------------------------------------------------
@queertypes
queertypes / Main.purs
Created August 31, 2015 05:06
Fun with Factorials: a purescript-halogen example
module Main where
import Prelude
import Control.Monad.Aff (runAff)
import Control.Monad.Eff (Eff())
import Control.Monad.Eff.Exception (throwException)
-- *very* explicit imports for slightly easier reading in a gist
import Data.Maybe (Maybe(Just, Nothing), maybe)