Skip to content

Instantly share code, notes, and snippets.

View cdparks's full-sized avatar
🍓

Chris Parks cdparks

🍓
View GitHub Profile
@cdparks
cdparks / Compact.cmm.diff
Created August 25, 2017 18:06
Trying to compact typeclass dictionaries being carried around by constructors
diff --git a/rts/Compact.cmm b/rts/Compact.cmm
index 72ad4dd437..a4b2d9b2ef 100644
--- a/rts/Compact.cmm
+++ b/rts/Compact.cmm
@@ -121,17 +121,49 @@ eval:
}
// We shouldn't see any functions, if this data structure was NFData.
+
+ case
import Data.Char (ord)
main = print $ rot13 "unccl oveguqnl, funqra!"
where
rot13 = foldr replace []
alpha = ['a'..'z']
index x = (ord x - ord 'a' + 13) `mod` 26
replace x xs
| x `elem` alpha = alpha !! index x:xs
| otherwise = x:xs
@cdparks
cdparks / Main.hs
Created June 22, 2015 16:31
Generic RNF
{-# LANGUAGE DeriveGeneric #-}
module Main where
import Control.DeepSeq
import Control.DeepSeq.Generics (genericRnf)
import GHC.Generics
data List a = Nil | Cons a (List a) deriving (Generic)
@cdparks
cdparks / gist:f18373921c7a59156cd7
Created March 21, 2015 18:16
Partially initialized record
data Point2D = Point2D { x :: Double, y :: Double }
p = Point2D { x = 1 }
-- Point2D (D# 1.0) (recConError "x.hs:3:5-21|y"#)
main = do
print (x p)
print (y p) -- BOOM