Skip to content

Instantly share code, notes, and snippets.

View sjakobi's full-sized avatar

Simon Jakobi sjakobi

View GitHub Profile
{-# language MagicHash #-}
-- | 'Char#' '-#' '<=##' '#' @'succ#'0#@ 'Bool'
module Lib where
import GHC.Prim
succ# :: Int# -> Int#
succ# = (+# 1#)
@sjakobi
sjakobi / SplitUtf8StringSpec.hs
Created November 10, 2018 01:31
SplitUtf8StringSpec.hs
{-# language BangPatterns, MagicHash, UnboxedTuples, MultiWayIf #-}
module Main (main, spec) where
import Test.Hspec
import Test.QuickCheck
import Data.ByteString
import qualified Data.ByteString as BS
import qualified Data.ByteString.Internal as BS
import Foreign
@sjakobi
sjakobi / stack.yaml
Last active November 23, 2016 17:27
Stack project configuration with a development version of bound which is compatible with GHC-8.0
packages:
- '.'
- location:
git: https://github.com/ekmett/bound
commit: 0a3666b
extra-dep: true
resolver: nightly-2016-11-23
@sjakobi
sjakobi / import-counts
Last active May 18, 2016 01:21
Modules imported by stack by number of modules
~/src/stack $ git grep -h "^import" src | grep -v Stack | sed 's/qualified//' | sed 's/import *//' | sed 's/".*" *//' | cut -d' ' -f1 | sort | uniq -c | sort -n -r
113 Data.Text
56 Data.Set
55 Path
55 Control.Monad.Catch
52 Control.Monad.Logger
51 Prelude
50 Data.Monoid
50 Control.Monad
48 Data.Map
This file has been truncated, but you can view the full file.
Wed Apr 27 06:23 2016 Time and Allocation Profiling Report (Final)
stack-e6536a-prof +RTS -p -RTS build
total time = 1.07 secs (1073 ticks @ 1000 us, 1 processor)
total alloc = 918,515,576 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
get Data.Vector.Binary 9.4 17.7
@sjakobi
sjakobi / 125_predict_the_number.hs
Last active August 29, 2015 13:56
Some timings for code_eval challenge 125
import Data.Bits (popCount)
import Data.Char (intToDigit)
import Data.List (intersperse)
import System.Environment (getArgs)
digitAt :: Integer -> Char
digitAt = intToDigit . (`rem` 3) . popCount
main = do
(fileName:_) <- getArgs
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c]
zipWith' _ [] _ = []
zipWith' _ _ [] = []
zipWith' f (x:xs) (y:ys) = f x y : zipWith' f xs ys
@sjakobi
sjakobi / Shell output
Last active December 26, 2015 20:08
Fresh IHaskell install, everything seems to be working fine now!
$ ipython --version
1.1.0
$ python --version
Python 2.7.3
$ which IHaskell
/home/simon/.cabal/bin/IHaskell
$ IHaskell setup
$ IHaskell console
Python 2.7.3 (default, Sep 26 2013, 16:35:25)
Type "copyright", "credits" or "license" for more information.