Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Jakobi sjakobi

View GitHub Profile
View Lib.hs
{-# language MagicHash #-}
-- | 'Char#' '-#' '<=##' '#' @'succ#'0#@ 'Bool'
module Lib where
import GHC.Prim
succ# :: Int# -> Int#
succ# = (+# 1#)
@sjakobi
sjakobi / SplitUtf8StringSpec.hs
Created Nov 10, 2018
SplitUtf8StringSpec.hs
View 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 Nov 23, 2016
Stack project configuration with a development version of bound which is compatible with GHC-8.0
View stack.yaml
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
Modules imported by stack by number of modules
View import-counts
~/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
View stack-e6536a-prof.prof
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
@sjakobi
sjakobi / 125_predict_the_number.hs
Last active Aug 29, 2015
Some timings for code_eval challenge 125
View 125_predict_the_number.hs
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
View fib.hs
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 Dec 26, 2015
Fresh IHaskell install, everything seems to be working fine now!
View Shell output
$ 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.