Skip to content

Instantly share code, notes, and snippets.

michaelt michaelt

Block or report user

Report or block michaelt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TestStreamUtf8.hs
{-#LANGUAGE ScopedTypeVariables#-}
import Test.QuickCheck hiding ((.&.))
import Test.Framework (Test, testGroup, defaultMain)
import Test.Framework.Providers.QuickCheck2 (testProperty)
import Debug.Trace (trace)
import Control.Exception (SomeException, evaluate, try)
import System.IO.Unsafe (unsafePerformIO)
import Data.Bits ((.&.))
@michaelt
michaelt / bench.txt
Created Feb 13, 2014
benchmarks for streamUtf8
View bench.txt
benchmarking lazy text
mean: 3.904823 ms, lb 3.844596 ms, ub 4.018289 ms, ci 0.950
std dev: 410.2641 us, lb 239.7706 us, ub 612.5513 us, ci 0.950
benchmarking new conduit
mean: 7.473182 ms, lb 7.354699 ms, ub 7.651235 ms, ci 0.950
std dev: 739.4707 us, lb 538.1933 us, ub 975.3947 us, ci 0.950
View utf8-bench.hs
{-# LANGUAGE RankNTypes #-}
import Data.Conduit
import qualified Data.Conduit.Text as CT
import Criterion.Main
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Encoding as TLE
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
import qualified Data.Conduit.List as CL
@michaelt
michaelt / parser.hs
Created Feb 20, 2014
parser zoom trouble
View parser.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns#-}
{-# LANGUAGE RankNTypes #-}
import Blaze.ByteString.Builder (Builder, fromByteString, toByteString)
import Control.Exception (Exception)
import Control.Monad.Trans.Class (lift)
import Data.ByteString (ByteString)
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
import Data.Monoid
@michaelt
michaelt / kate.html
Last active Aug 29, 2015
DataHinds syntax highlighting
View kate.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
@michaelt
michaelt / lines_url.hs
Created Jul 20, 2014
number lines XLVIII
View lines_url.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE LambdaCase #-}
-- https://gist.github.com/michaelt/88e1fac12876857deefe
-- following
-- https://gist.github.com/gelisam/c769d186493221d7ebbe and associated controversy.
module Main where
View Main.hs
{-# LANGUAGE OverloadedStrings #-}
import Pipes
import Pipes.Group
import qualified Pipes.Prelude as P
import qualified Pipes.ByteString as PB
import qualified Pipes.Attoparsec as PA
import Data.Aeson
import Data.Aeson.Parser
import Data.Aeson.Types
import Data.Monoid
View gist:fa2c8ceb9fb8ddbe1538
data Primitive = Num
|Chr
|Str
|Cnd Bool deriving (Show)
data T = K Int | R Int
-- >>> :set -XDataKinds
-- >>> :t Num
-- Num :: Primitive
-- >>> :k Num
View gist:7ef6ec1824fb638be203
{-#LANGUAGE RebindableSyntax, RecordWildCards, CPP, OverloadedStrings #-}
import Data.Monoid
import Prelude
import Control.Monad
import Data.String
import Text.Blaze.Html5 as H
import Text.Blaze.Html5.Attributes as A
import qualified Text.Blaze as B
@michaelt
michaelt / Parse.hs
Last active Aug 29, 2015
serialize and deserialize FastaSequences as Text
View Parse.hs
-- Parse module.
-- By G.W. Schwartz
--
{- | Collection of functions for the parsing of a fasta file. Uses the Text
type.
-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
You can’t perform that action at this time.