Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances,
TypeOperators, UndecidableInstances #-}
import Data.Constraint
import Data.Constraint.Forall
class C1 a b
class C2 a b
instance C1 a b => C2 a b
@UnkindPartition
UnkindPartition / results
Created January 11, 2017 10:19
forM_ speed test
benchmarking vec base
time 15.54 μs (15.43 μs .. 15.63 μs)
1.000 R² (1.000 R² .. 1.000 R²)
mean 15.45 μs (15.40 μs .. 15.51 μs)
std dev 180.4 ns (157.0 ns .. 209.1 ns)
benchmarking vec roman
time 16.86 μs (16.77 μs .. 16.95 μs)
1.000 R² (1.000 R² .. 1.000 R²)
mean 16.86 μs (16.81 μs .. 16.92 μs)
@UnkindPartition
UnkindPartition / run.sh
Created January 11, 2017 09:49
forM_ memory test
for n in 5000 50000 500000 5000000; do
for impl in roman michael base; do
printf "%7d %10s" $n $impl
./test4 $impl $n +RTS -s 2>&1|perl -lne '/(^.*bytes).*residency/&&print $1'
done
done
@UnkindPartition
UnkindPartition / combined_to_csv
Created March 19, 2016 13:48
Transform combined http log into an R-compatible CSV file
#!/usr/bin/perl
# (c) Roman Cheplyaka, 2016
# License: MIT
# Usage:
#
# combined_to_csv FILE1 FILE2 ... > FILE.csv
#
# The resulting CSV file can be read in R with:
@UnkindPartition
UnkindPartition / cleanup.sh
Created March 11, 2016 21:27
Clean up stale .sdr files from Kindle (paperwhite)
#!/bin/sh
# Call this from your 'documents' directory
set -eu
for d in *.sdr
do
if [ -d "$d" -a ! -n "$(find . -maxdepth 1 -type f -name "${d%.sdr}*" -print -quit)" ]
then
echo "$d"
{-# LANGUAGE
ScopedTypeVariables,
TemplateHaskell,
TypeFamilies,
GADTs,
KindSignatures,
DataKinds,
PolyKinds,
TypeOperators,
FlexibleContexts,
{-# LANGUAGE GADTs, DataKinds, TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
data Nat = Z | S Nat
data m <= n where
Le_z :: (n <= n)
Le_s :: (m <= n) -> (m <= S n)
type (m < n) = (S m <= n)
import Control.Monad.Logic
import Control.Monad.Trans.Maybe
zipLogic :: (MonadLogic m) => m a -> m b -> m (a, b)
zipLogic gx gy =
maybe mzero return <=< runMaybeT $ do
(x, rx) <- MaybeT (msplit gx)
(y, ry) <- MaybeT (msplit gy)
lift $ return (x, y) `mplus` zipLogic rx ry
pub enum RE<S, F:Fn(S,bool)> {
Eps,
Symbol(F)
}