Skip to content

Instantly share code, notes, and snippets.

View michaelt's full-sized avatar

michaelt michaelt

  • twitter antiphasis_
View GitHub Profile
@michaelt
michaelt / amity.hs
Created December 3, 2010 16:23 — forked from DylanLukes/amity.hs
with idiom brackets in minecraft.hs
import System.IO
import Network
import Minecraft
import Control.Monad
import Control.Monad.Fix
import Control.Monad.Trans
import Control.Monad.BinaryProtocol
import Control.Concurrent
import Control.Concurrent.STM
import Control.Concurrent.STM.TChan
@michaelt
michaelt / Jade.hs
Created May 6, 2012 19:13 — forked from scan/Jade.hs
Jade2.hs
{-#LANGUAGE OverloadedStrings#-}
module Jade where
import Text.Parsec
import qualified Text.Parsec.Token as L
import Text.Parsec.Language (emptyDef)
import Text.Parsec.Text (Parser)
import Data.Text (Text)
import Control.Monad (mzero)
import Control.Applicative ((<$>),(*>), (<*))
(☃) :: Int -> Int -> Int
x ☃ y = x + y
main = print $ 0 ☃ 1 ☃ 2
@michaelt
michaelt / RedBlackTree.hs
Created May 11, 2012 15:01 — forked from rampion/RedBlackTree.hs
red-black trees in haskell, using GADTs and Zippers (and DataKinds)
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DataKinds#-}
{-# LANGUAGE KindSignatures#-}
module RedBlackTree where
data Nat = Zero | Succ Nat deriving (Eq, Ord, Show)
type One = Succ Zero
@michaelt
michaelt / UninstallHS.hs
Created May 22, 2012 23:54 — forked from mzero/UninstallHS.hs
Mac OS X Haskell Uninstaller preview
#!/usr/bin/env runghc
module Main where
{-
Uninstall.hs - a Haskell uninstaller for Mac OS X
This program is really far too big to be in a single file. However, I
wanted it to be easily distributable and runnable, and so have kept it all
together.
@michaelt
michaelt / asyncidiom.hs
Created June 23, 2012 16:35 — forked from sjoerdvisscher/asyncidiom.hs
Applicative async programming
import Control.Concurrent
import Control.Concurrent.Async
import Control.Applicative
import Control.Monad
import Data.Traversable
newtype Concurrently a = Concurrently { runConcurrently :: IO a }
instance Functor Concurrently where
@michaelt
michaelt / asyncidiom.hs
Created June 23, 2012 16:35 — forked from sjoerdvisscher/asyncidiom.hs
Applicative async programming
{-# LANGUAGE ImplicitParams, ParallelListComp,MonadComprehensions #-}
import Control.Monad
import Control.Monad.Fix
import Control.Monad.Zip
import Control.Applicative
import Control.Concurrent
import Control.Concurrent.MVar
import Control.Exception
import Prelude -- hiding (catch)
import Data.IORef
@michaelt
michaelt / html.hs
Created July 28, 2012 17:14 — forked from LnL7/html.hs
module HTML where
class Tag a where
toHTML :: a -> String
data Attribute = Attribute {
key :: String,
value :: String
} deriving Show
@michaelt
michaelt / gist:3847032
Created October 7, 2012 03:50
parsepacket
countPackets p =
let v = AL.parse (CA.many packetValue) p
r = fromMaybe [] $ AL.maybeResult v
in r
@michaelt
michaelt / gist:5568429
Last active December 17, 2015 06:49 — forked from reite/gist:5568152
{-#LANGUAGE OverloadedStrings#-}
import Data.Aeson.Types
import Data.Aeson
import qualified Data.Vector as V
import qualified Data.ByteString.Lazy as L
import Data.HashMap.Strict
import qualified Data.Text as T
-- this is backward maybe -- also doesn't crack open the Values