Skip to content

Instantly share code, notes, and snippets.

@nomeata
nomeata / GC-Anim.hs
Last active August 29, 2015 14:02
GC animation
{-# LANGUAGE ViewPatterns, GeneralizedNewtypeDeriving, DeriveDataTypeable#-}
import Diagrams.Prelude
import Diagrams.Backend.Cairo.CmdLine
import Diagrams.TwoD.Vector
import Diagrams.Core.Types
import qualified Data.Monoid.MList
import Data.Monoid.Coproduct
import Data.Typeable
Theorem insert_perm: forall k l, Permutation (k :: l) (insert k l).
Proof.
intros. induction l.
- reflexivity.
- simpl. destruct (ble_nat k a).
+ reflexivity.
+ transitivity (a :: k :: l).
* apply perm_swap.
* constructor; assumption.
Qed.
{-# LANGUAGE TupleSections #-}
module SeqCP where
import Data.Sequence
import Prelude hiding (drop, take, length, splitAt)
import Test.QuickCheck ((===), (==>), Property, Positive(..))
data CPs x y =
Empty |
SingleCP x (Seq y) |
@nomeata
nomeata / Main.hs
Created April 25, 2015 21:18
CodinGame „There is no Spoon“ World Cup entry
import System.IO
import Control.Monad
import qualified Data.Map.Strict as M
import qualified Data.Set as S
import Text.Printf
import Data.List
type Node = (Int,Int)
type Link = (Node, Node)
@nomeata
nomeata / gist:071c1f87450cf668bbeb
Created May 21, 2015 14:54
Compiling Stackage LTS 2.9 (GHC 7.8.4) with -ddump-rule-firings
291212 Rule fired: unpack
290940 Rule fired: unpack-list
180247 Rule fired: tagToEnum#
147567 Rule fired: Class op return
128770 Rule fired: ++
125196 Rule fired: Class op >>=
108321 Rule fired: foldr/app
86067 Rule fired: Class op >>
62107 Rule fired: Class op ==
61679 Rule fired: Class op showsPrec
@nomeata
nomeata / demo.sh
Last active August 29, 2015 14:27
shake UI demo
#!/bin/bash
while read -u 3 line
do
if [ "$line" == "====" ]
then
read -n 0
clear
else
echo $line
{-# LANGUAGE RecursiveDo #-}
import Reflex.Dom
import qualified Data.Map as M
import Data.Monoid
import Control.Applicative
main = mainWidget $ el "div" $ do
(svg, ()) <- buildElementNS mns "svg" ("width" =: "300" <> "height" =: "300") $ mdo
circle <- wrapElement =<< buildEmptyElementNS mns "circle"
("cx" =: "100" <> "cy" =: "100" <> "r" =: "100" <> "fill" =: "red")
-> case (compare a1_acXB b1_acXJ) of {
LT -> LT
EQ
-> case (compare a2_acXC b2_acXK) of {
LT -> LT
EQ
-> case (compare a3_acXD b3_acXL) of {
LT -> LT
EQ
-> case (compare a4_acXE b4_acXM) of {
@nomeata
nomeata / gist:cf7960caeb0b2c1697b8
Created September 29, 2015 11:47
How does that get slower?
- go [Occ=LoopBreaker] :: Integer -> Int -> [Integer]
- [LclId, Arity=1, Str=DmdType <L,U>]
- go =
- \ (x :: Integer) ->
- let {
- xs [Dmd=<L,C(U)>] :: Int -> [Integer]
- [LclId, Str=DmdType]
- xs =
- go
- (case eqInteger# w2 lvl3 of wild4 { __DEFAULT ->
@nomeata
nomeata / gist:c1c7f737a978caa8bf06
Created October 1, 2015 09:49
Strange perf results
$ for x in ghc-7.10-no-call-arity-no-oneshot-plain-foldl ghc-7.10-plain-foldl; do perf stat -r 5 -e cache-references,cache-misses,cycles,instructions,branches,faults,migrations ./$x/nofib/spectral/knights/knights 32 6 +RTS -I0 -V0 -t >/dev/null; done
<<ghc: 330477432 bytes, 632 GCs, 370333/982272 avg/max bytes residency (3 samples), 3M in use, 0.000 INIT (0.000 elapsed), 0.934 MUT (0.934 elapsed), 0.024 GC (0.024 elapsed) :ghc>>
<<ghc: 330477432 bytes, 632 GCs, 370333/982272 avg/max bytes residency (3 samples), 3M in use, 0.000 INIT (0.000 elapsed), 0.933 MUT (0.933 elapsed), 0.024 GC (0.024 elapsed) :ghc>>
<<ghc: 330477432 bytes, 632 GCs, 370333/982272 avg/max bytes residency (3 samples), 3M in use, 0.000 INIT (0.000 elapsed), 0.933 MUT (0.933 elapsed), 0.024 GC (0.024 elapsed) :ghc>>
<<ghc: 330477432 bytes, 632 GCs, 370333/982272 avg/max bytes residency (3 samples), 3M in use, 0.000 INIT (0.000 elapsed), 0.933 MUT (0.934 elapsed), 0.024 GC (0.024 elapsed) :ghc>>
<<ghc: 330477432 bytes, 632 GCs, 370333/98227