Skip to content

Instantly share code, notes, and snippets.

View harendra-kumar's full-sized avatar

Harendra Kumar harendra-kumar

View GitHub Profile
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
@harendra-kumar
harendra-kumar / streamly-type.hs
Created January 25, 2019 07:05
streamly-type
{-# 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 September 29, 2017 14:23
Mandatory and optional keyword arguments with default values for Haskell using rawr anonymous records
#!/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
# 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