Skip to content

Instantly share code, notes, and snippets.

View 23Skidoo's full-sized avatar

Mikhail Glushenkov 23Skidoo

View GitHub Profile
@23Skidoo
23Skidoo / meta02_VNM.10.0.7.10_9.log
Created April 19, 2011 07:55
[meta02_VNM.10.0.7.10_9.log] FAIL
Interesting call: 145; interesting frame number: 2
Interesting call: 20; interesting frame number: 1
Interesting call: 66; interesting frame number: 0
Interesting call: 241; interesting frame number: 0
Interesting call: 241; interesting frame number: 2
Interesting call: 66; interesting frame number: 0
Interesting call: 295; interesting frame number: 0
Interesting call: 382; interesting frame number: 2
Interesting call: 347; interesting frame number: 0
Interesting call: 310; interesting frame number: 2
@23Skidoo
23Skidoo / Main.hs
Created May 4, 2011 22:33
Data.Map.lookup without Maybe
module Main
where
import Control.Exception
import Data.Map as M
import Data.Maybe
-- Well, since you don't have any constraints on the type of the input argument,
-- you can't be absolutely sure that your function will be always used
-- correctly. I too would use an assertion here (or change my function to return
@23Skidoo
23Skidoo / myZcat.hs
Created May 7, 2011 15:34
zcat with iterIO
module Main
where
import Control.Monad.IO.Class (MonadIO)
import Data.ByteString.Lazy (ByteString)
import Data.IterIO
import Data.IterIO.Zlib (inumGunzip)
import System.Environment
import System.IO
@23Skidoo
23Skidoo / Trace.hs
Created May 8, 2011 11:06
Modified sequencing monad
-- See
-- http://stackoverflow.com/questions/5920200/how-to-prevent-common-sub-expression-elimination-cse-with-ghc
module Main
where
import Debug.Trace
data Eval a = Done a
| Trace String a
@23Skidoo
23Skidoo / SomeStruct.hs
Created May 19, 2011 18:51
Experiments with unboxed mutable records
module Main
where
import Control.Monad
import Data.IORef
data SomeStruct = SomeStruct { someField :: {-# UNPACK #-} !Int,
someOtherField :: {-# UNPACK #-} !Int,
yetAnotherField :: {-# UNPACK #-} !Float }
@23Skidoo
23Skidoo / GSoC.hs
Created May 20, 2011 07:14
GSoC project prototype
module Main
where
import Control.Concurrent
import Control.Monad
import Data.Map((!))
import qualified Data.Map as M
import System.Environment(getArgs)
-- The program consists of several threads which communicate via Chans. There
@23Skidoo
23Skidoo / DoWeNeedDependentTypes.hs
Created June 20, 2011 14:38
zipWith with variable number of arguments
module Main
where
-- See "Do We Need Dependent Types?" by Fridlender & Indrika
-- http://www.brics.dk/RS/01/10/
(<<) :: [a -> b] -> [a] -> [b]
(f:fs) << (a:as) = f a : (fs << as)
_ << _ = []
@23Skidoo
23Skidoo / gist:1038315
Created June 21, 2011 16:57
Wrong SO answer illustration
http://stackoverflow.com/questions/6411771/nested-triangular-loop-in-haskell/6413934
Java version:
0.06072334190603272
2.590520221772998
5.098582403887274
7.59983261470893
10.096589520693144
12.588688490747979
@23Skidoo
23Skidoo / Bench.hs
Created June 22, 2011 00:11
Functional vs. imperative nested triangular loops
module Main
where
-- See http://stackoverflow.com/questions/6411771/nested-triangular-loop-in-haskell
import Control.DeepSeq
import Criterion.Main
import Data.Array
import Data.List (tails)
@23Skidoo
23Skidoo / TChan.hs
Created June 22, 2011 13:57
Example of bad TChan usage
-- See http://stackoverflow.com/questions/6439925/poor-performance-lockup-with-stm
{-# LANGUAGE BangPatterns #-}
module Main where
import Control.Concurrent.STM
import Control.Concurrent
import System.Random(randomRIO)
import Control.Monad(forever, when)