Skip to content

Instantly share code, notes, and snippets.

@AndreasPK
AndreasPK / Curious.hs
Created February 19, 2018 10:12
On GHC-8.2 this code is faster in GHCi then when compiled.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.Text as T
import Data.Text (Text(..))
longestCommonSubstring :: [Text] -> Text
longestCommonSubstring entries = go [""] "" where
#!/usr/bin/env bash
LOGNAME=$1
LOG_DIR=~/logs4
TREE_DIR=~/trees4
RUNS=7
if [ -z "$1" ]
then
@AndreasPK
AndreasPK / ReportSoC_2018.md
Last active August 14, 2018 15:26
Final report - SoC 2018 - Andreas Klebinger

Improvements to GHCs Code Generator

This is a writeup of the work done by me (Andreas Klebinger) during my SoC 2018 Project.

Improved code layout for GHC

The vast majority of my time was spent working on this part of the Project. While the patch was not yet merged there is not much missing.

Consider a simple definition using guards:
foo x
| x == C1 = { -# LIKELY 10 #- } e1
| otherwise = { -# LIKELY 0 #- } e2
with C1 being defined by T using uniform default weights:
data T = {-# LIKELY 1000 #-} C1
| 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
{
@AndreasPK
AndreasPK / Day21.reddit.hs
Created February 6, 2019 23:43
Mutable day 21
#!/usr/bin/env stack
{-
stack
script
--resolver lts-12.20
--package text,trifecta,containers,parsers,mtl,vector,deepseq
-}
{-# LANGUAGE RecordWildCards, BangPatterns #-}
{-# OPTIONS_GHC -O2 #-}
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
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
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] -> ()