Skip to content

Instantly share code, notes, and snippets.

Avatar

AndreasPK

  • Vienna, Austria
View GitHub Profile
View Packing
{- | Pack types of a known size into as few bytes as possible.
We do so by assigning each instance of the Packable class
a 'Width' in bits.
When combining types we add up their widths using type level computation.
-}
{-# LANGUAGE TypeFamilies #-}
View muchCoreSuchWow.hs
==================== Tidy Core ====================
Result size of Tidy Core
= {terms: 17,361, types: 21,327, coercions: 5,089, joins: 99/404}
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
$trModule2 = "Load"#
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
View Download hackage
# First get a list of all packages
cabal list --simple | tee packages.list
# Then compute the locations of their tar files
python3 -c "from fileinput import *; [print(\"https://hackage.haskell.org/package/\"+p+\"/\"+p+\"-\"+ver+\".tar.gz\") for (p,ver) in sorted(dict(map(str.split, input())).items())]" < packages.list | tee files.list
# If you are on windows make sure python didn't use CRLF:
# dos2unix files.list
# Download all the archives - 4 at a time. Some might fail, that is expected.
@AndreasPK
AndreasPK / GHC String->Core
Created Jan 23, 2020
Compile a String to a CoreExpr
View GHC String->Core
module Main where
import GHC
import CoreSyn
import Inst
import Desugar
import TcRnMonad
import TcHsSyn
import RnExpr
import GhcMonad
@AndreasPK
AndreasPK / gist:14bd8376fb48e27b0858d57270e2a956
Created Oct 15, 2019
ghc performance diffs 8.6.5 vs 8.8 vs 8.10*(patch branch)
View gist:14bd8376fb48e27b0858d57270e2a956
Andi@Horzube MINGW64 /e/pan-os-syslog
$ cabal new-run bench -w /e/ghc_layout/_quick/stage1/bin/ghc.exe --allow-newer="*"
Up to date
benchmarking 8-1-Traffic-A ...
benchmarked 8-1-Traffic-A
time 626.4 ns (611.3 ns .. 647.4 ns)
0.987 R² (0.971 R² .. 0.997 R²)
mean 618.7 ns (610.2 ns .. 634.3 ns)
std dev 38.10 ns (25.20 ns .. 65.38 ns)
variance introduced by outliers: 39% (moderately inflated)
View matchFailure.hs
compiler\nativeGen\X86\CodeGen.hs:169:1: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In an equation for `verifyBasicBlock':
Patterns not matched: _ :: [Instr]
|
169 | verifyBasicBlock instrs
-- Verifying basic blocks is cheap, but not cheap enough to enable it unconditionally.
verifyBasicBlock :: [Instr] -> ()
View gist:42cdc931ec29b2ce4cc6b551093e9407
Tue Aug 27 19:56 2019 Time and Allocation Profiling Report (Final)
ghc.exe +RTS -p -RTS Main.hs --make -O -fforce-recomp
total time = 7.72 secs (7721 ticks @ 1000 us, 1 processor)
total alloc = 9,747,651,160 bytes (excludes profiling overheads)
COST CENTRE MODULE SRC %time %alloc
simplIdF Simplify compiler\simplCore\Simplify.hs:899:61-79 16.9 18.1
View gist:4c2258d73cf37bf90babcb7ee190423f
Tue Aug 27 19:56 2019 Time and Allocation Profiling Report (Final)
ghc.exe +RTS -p -RTS Main.hs --make -O -fforce-recomp
total time = 7.72 secs (7721 ticks @ 1000 us, 1 processor)
total alloc = 9,747,651,160 bytes (excludes profiling overheads)
COST CENTRE MODULE SRC %time %alloc
simplIdF Simplify compiler\simplCore\Simplify.hs:899:61-79 16.9 18.1
View Day21.reddit.hs
#!/usr/bin/env stack
{-
stack
script
--resolver lts-12.20
--package text,trifecta,containers,parsers,mtl,vector,deepseq
-}
{-# LANGUAGE RecordWildCards, BangPatterns #-}
{-# OPTIONS_GHC -O2 #-}
View gist:91035fbf77694bf1bd509f60ff679479
| x == A = e1
| x == B = e2
| predFunc(x) = e3
case (case x of { C1 -> (Weight: 1000) A;
C2 -> (Weight: 1000) B;
C3 -> (Weight: 1000) e3; } ) of
{
You can’t perform that action at this time.