Skip to content

Instantly share code, notes, and snippets.

Avatar

Harendra Kumar harendra-kumar

View GitHub Profile
View Streamly benchmarks GHC 8.6.5 vs 8.9-head
100,000 elems(time)
Benchmark default(0)(μs) default(1)(μs)
-------------------------------------------- -------------- --------------
serially/folds/product 100.58 32.77
serially/elimination/product 99.08 32.82
serially/elimination/findIndex 137.68 49.30
serially/transformationX4/mapMaybeM 84.04 32.87
serially/generation/intFromThenTo 75.48 32.12
serially/generation/unfoldr 76.49 32.96
serially/elimination/last 72.76 32.34
View streamly-type.hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
import Control.Monad.Trans.Class
import Control.Monad
newtype Stream m a = Stream
{ runStream :: (forall r. (a -> Stream m a -> m r) -> m r -> m r) }
@harendra-kumar
harendra-kumar / keyword-args.hs
Created Sep 29, 2017
Mandatory and optional keyword arguments with default values for Haskell using rawr anonymous records
View keyword-args.hs
#!/usr/bin/env stack
-- stack runghc --package rawr
-- ---------------------------------------------------------------------------
-- This code snippet demonstrates using keyword arguments with default values
-- in Haskell using the rawr anonymous records library. Supported features:
--
-- 1) Specify arguments using keywords
-- 2) Make some arguments mandatory and others optional
-- 3) Assign default values to optional arguments
View decompose-loop-execution-trace-ghc-7.10.3.asm
# GHC 7.10.3 NO llvm
# Start of loop
# c4ic:
# Heap check + 48
=> 0x408d2a: add $0x30,%r12
=> 0x408d2e: cmp 0x358(%r13),%r12
=> 0x408d35: ja 0x4094af
# c4mw:
# Loop realloc check logic