Skip to content

Instantly share code, notes, and snippets.

View rahulmutt's full-sized avatar

Rahul Muttineni rahulmutt

View GitHub Profile
@rahulmutt
rahulmutt / zig0.heaptrack.log
Created March 16, 2022 19:59
Heaptrack for zig0 in self-hosted build
reading file "/home/ubuntu/Development/zig/heaptrack.zig0.17870.gz" - please wait, this might take some time...
Debuggee command was: /home/ubuntu/Development/zig/build/zig0 src/stage1.zig -target native -mcpu=baseline --name zig1 --zig-lib-dir /home/ubuntu/Development/zig/lib -femit-bin=/home/ubuntu/Development/zig/build/zig1.o -fcompiler-rt -lc --pkg-begin build_options /home/ubuntu/Development/zig/build/config.zig --pkg-end --pkg-begin compiler_rt /home/ubuntu/Development/zig/lib/std/special/compiler_rt.zig --pkg-end
finished reading file, now analyzing data:
MOST CALLS TO ALLOCATION FUNCTIONS
82221641 calls to allocation functions with 5.34G peak consumption from
mem::os::calloc(unsigned long, unsigned long)
at /home/ubuntu/Development/zig/src/stage1/mem.hpp:71
in /home/ubuntu/Development/zig/build/zig0
2369219 calls with 113.63M peak consumption from:
@rahulmutt
rahulmutt / Main.hs
Last active April 9, 2019 09:24
Fast set union w/ type-level lists
{-# LANGUAGE TypeFamilies
, DataKinds
, PolyKinds
, UndecidableInstances
, DeriveGeneric
, TypeOperators #-}
module Main where
import GHC.Generics
import GHC.TypeLits
@rahulmutt
rahulmutt / gist:1da88766cb5b321ba2f7721cf844dde5
Last active July 11, 2018 05:15
Derivation involving (->) applicative instance
lift2 :: (Applicative f) = > (a -> b -> c) -> f a -> f b -> f c
----------
(\a -> State (\s -> (p a s, S.insert a s)))
=> Split up s function into component-wise functions [Definition of lift2 for (->)]
lift2 :: (a -> b -> c) -> (s -> a) -> (s -> b) -> (s -> c)
lift2 :: (a -> b -> (a, b)) -> (s -> a) -> (s -> b) -> (s -> (a, b))
@rahulmutt
rahulmutt / Overview.md
Last active June 30, 2018 03:17
Eta IDE Support
@rahulmutt
rahulmutt / Conv.hs
Created March 1, 2018 02:34
Convert CharSequence to StringBuffer
charSeqToStringBuffer :: CharSequence -> StringBuffer
charSeqToStringBuffer cs = unsafePerformJava $ do
bytes <- charSequenceBytes cs
len <- bytes <.> alength
buf <- mallocForeignPtrArray len
io $ withForeignPtr buf $ putBytesIntoPtr bytes
return $ StringBuffer { cur = 0, .. }
foreign import java unsafe "@static Utils.charSequenceBytes" charSequenceBytes
@rahulmutt
rahulmutt / Spec.md
Last active January 12, 2018 01:11
Eta FFI Specification

Eta FFI Specification

Architecture

The Eta FFI Generator will consist of support from three components:

  • The Eta compiler
  • The Etlas build tool
  • The eta-ffi tool

Eta Compiler

@rahulmutt
rahulmutt / Main-Decompiled.java
Last active September 12, 2017 04:34
Polymorphism in Eta via Type Erasure
public static class id extends Function {
public Closure enter(StgContext context) {
// context.R(2) is the first argument of the function
// All id simply does is evaluate the argument -
// it cannot do much more!
return context.R(2).evaluate(context);
}
public int arity() { return 1; }
}
@rahulmutt
rahulmutt / Main.hs
Last active October 1, 2020 04:44
Fast coproducts for Haskell & Eta
#!/usr/bin/env stack
{- stack
--resolver lts-6.27
--install-ghc
runghc
--package containers
-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
@rahulmutt
rahulmutt / Transform.hs
Last active August 9, 2017 02:47
Code for Eta <-> Scala blog post
module Example.Transform where
import Java
import Control.Lens
import Data.Aeson
import Data.Aeson.Lens
import Data.Text (Text)
import qualified Data.Text as T
@rahulmutt
rahulmutt / data.json
Created August 8, 2017 23:40
eta-scala-1
{
"id": 1,
"first_name": "Jerrold",
"last_name": "Hache",
"email": "jhache0@ca.gov",
"gender": "Male",
"ip_address": "149.180.165.206",
"events": {
"clicks": 99
}