Skip to content

Instantly share code, notes, and snippets.

View michaelt's full-sized avatar

michaelt michaelt

  • twitter antiphasis_
View GitHub Profile
{-#LANGUAGE TypeOperators, LambdaCase, BangPatterns, RankNTypes #-}
-- Needed for the MonadBase instance
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
{-#LANGUAGE ScopedTypeVariables #-}
module Loop where
import Control.Monad.Trans
import Control.Monad
@michaelt
michaelt / tutorial.hs
Created August 4, 2015 16:42
pipes concurrency tutorial
{-| This module provides a tutorial for the @pipes-concurrency@ library.
This tutorial assumes that you have read the @pipes@ tutorial in
@Pipes.Tutorial@.
I've condensed all the code examples into self-contained code listings in
the Appendix section that you can use to follow along.
-}
-- module Pipes.Concurrent.Tutorial
@michaelt
michaelt / chunkX.hs (splitAt defined with next)
Last active August 29, 2015 14:26
Pipes.splitAt defined with and without `next`
{-#LANGUAGE RankNTypes #-}
import Lens.Simple
-- import Control.Lens (view)
import Control.Monad
import qualified Data.List as L
import Data.Vector (Vector)
import qualified Data.Vector.Generic as V
import qualified Data.Vector.Generic.Mutable as VM
import Pipes
import Pipes.Group hiding (chunksOf)
@michaelt
michaelt / chunkX.hs core
Created August 7, 2015 15:37
core for pipes splitAt defined with and without next
chunkX.hs
==================== CorePrep ====================
Result size of CorePrep
= {terms: 634, types: 1,774, coercions: 269}
Rec {
$snext2
$snext2 =
\ @ a_XcUd @ r_XcUg p_sg9n eta_sg9o ->
@michaelt
michaelt / streamingtest.hs
Last active August 29, 2015 14:27
https://github.com/jwiegley/streaming-tests modified for use with `streaming`
module Main where
import qualified Streaming.Prelude as Str
import qualified System.IO.Streams as IOS
import Conduit.Simple as S
import Control.Exception
import Criterion.Main
import Data.Conduit as C
import Data.Conduit.Combinators as C
import Fusion as F hiding ((&))
@michaelt
michaelt / benchcsv.hs
Last active August 30, 2015 21:54
A benchmark of builder->lazy bytestring versus builder->streaming bytestring (originally it had a different purpose). See results below.
{-# LANGUAGE OverloadedStrings, PackageImports #-}
-- |
-- Copyright : (c) 2010-2011 Simon Meier
-- License : BSD3-style (see LICENSE)
--
-- Maintainer : Simon Meier <iridcode@gmail.com>
-- Stability : experimental
-- Portability : tested on GHC only
--
-- Running example for documentation of Data.ByteString.Lazy.Builder
@michaelt
michaelt / minecraft.hs
Created December 3, 2010 16:18
cabal install she + pragma + import Control.Applicative
{-# OPTIONS_GHC -F -pgmF she #-}
module Minecraft
( ClientToServerPacket(..)
, ServerToClientPacket(..)
, MCInventoryItem
, MCInventoryUpdate
, MCBlockChange
, MCMultiBlockChange
, MCExplosionRecords
) where
@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 / a.bib
Created December 9, 2011 11:02
a.bib
@article{nordstrom1993,
title={A prospective study},
author={Nordstr{\"o}m, M.},
journal={Journal of internal medicine},
volume={232},
number={2},
pages={155--160},
year={1992},
publisher={Wiley Online Library}
}
@michaelt
michaelt / default.scriptogram
Created February 23, 2012 14:44
pandoc + mathjax + scriptogr.am
---
$if(date)$
Date: $date$
$endif$
$if(title)$
Title: $title$
$endif$
---
<div>