Skip to content

Instantly share code, notes, and snippets.

View ndmitchell's full-sized avatar

Neil Mitchell ndmitchell

View GitHub Profile
@ndmitchell
ndmitchell / Rethinking.md
Created July 2, 2016 19:56
Shake - rethinking rules

I suspect the below isn't a good idea, because the remember needs repeating lots of times for every user of a rule. The new design seems to eliminate these issues more cleanly, but it's an interesting point in the design space.

Rethinking Rules

The current Rule typeclass has a number of issues. It's a bit complex to use, it often results in more dependencies than you were hoping, it's hard to control. People often end up defining oracles instead or rules but then you don't get options for other things. This document attempts to rethink that.

Concept

Shake runs rules that produce values. These rules track the current state of the system (other rules) and external values (files on disk). Currently the value produced by a rule is tracked automatically. This is often awkward. Imagine we want:

Each key gets intern'd into an Id
Key :-> Id
Id :-> Status
{-# LANGUAGE Rank2Types #-}
import qualified Core.IO as F
import qualified Core.String as F
import qualified Core.Array as F
import qualified Core.VFS as F
import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString as BS
import Codec.Compression.GZip as GZip
import Codec.Archive.Tar as Tar
@ndmitchell
ndmitchell / hlint.prof
Created January 24, 2017 21:51
Example of a profile report that displays badly in Profiteur
Tue Jan 24 08:33 2017 Time and Allocation Profiling Report (Final)
hlint +RTS -p -RTS src
total time = 2.27 secs (2274 ticks @ 1000 us, 1 processor)
total alloc = 42,443,280,112 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
uniplateData Data.Generics.Uniplate.Internal.Data 41.4 68.1

Haskell can be written using nothing more than a text editor, and most popular editors include Haskell syntax highlighting out of the box. In addition, some editors can be enhanced to provide IDE-like features, using the tools listed below.

Intero (Emacs enhancement)

  • Provides instant error feedback, completions, go to definition, applying suggestions, type of expression.
  • Works with GHC 7.8 onwards, benefits from Stack.
@ndmitchell
ndmitchell / DList.hs
Created April 23, 2017 19:52
DList benchmarks
{-# OPTIONS_GHC -O2 #-}
import Control.Monad
import Control.Exception
import System.Time.Extra
import Criterion.Main
type DList a = [a] -> [a]
dTo f = f []
@ndmitchell
ndmitchell / hlint.prof
Created June 2, 2017 20:53
HLint profile
This file has been truncated, but you can view the full file.
Thu Jun 01 08:33 2017 Time and Allocation Profiling Report (Final)
hlint +RTS -P -RTS src
total time = 1.24 secs (1242 ticks @ 1000 us, 1 processor)
total alloc = 2,511,288,344 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc ticks bytes
unifyExp Hint.Match 23.0 2.0 286 49844616
@ndmitchell
ndmitchell / hlint.profiterole.txt
Created June 2, 2017 20:54
hlint.profiterole.txt
TOT INH IND
51.0 47.4 - Hint.Match readMatch (53)
12.0 12.0 - Data.Generics.Uniplate.Internal.Data readCacheFollower (3)
10.3 10.2 .6 Language.Haskell.Exts parseFileContentsWithComments (53)
8.7 7.5 7.5 Data.Generics.Uniplate.Internal.Data uniplateData (1377837)
99.9 5.2 - MAIN MAIN (0)
2.9 2.8 2.0 Data.Generics.Uniplate.Internal.Data descendBiData (109203)
2.4 2.4 - HSE.All runCpp (53)
2.3 2.3 2.3 Data.Generics.Uniplate.Internal.Data typeKey (2721430)
1.9 1.5 1.5 Data.Generics.Uniplate.Internal.Data fromOracle (1031785)
@ndmitchell
ndmitchell / Code.hs
Created November 12, 2014 10:41
Hackage symbols
import System.Environment
import System.Directory.Extra
import Control.Exception.Extra
import System.FilePath
import Control.Monad
import System.IO.Extra
import Data.List.Extra
main = do
[dir,out] <- getArgs
@ndmitchell
ndmitchell / policies.md
Created June 12, 2017 20:55
Friendly contribution policies

This is intended as a reply to https://ro-che.info/articles/2017-06-12-friendly-contributing-policies, but I don't really want it to be a blog post (it's not the right level for my blog), and that blog doesn't have comments, and I don't want to mis-express myself in 120 characters or whatever. So here goes a gist :)

Firstly, as to the talk, the context was read around the project, and figure out if it will suit you. I am deliberately quoting haskell-src-exts out of context, and deliberately not saying where either quote came from. I appreciate the full policy is much more welcoming than that one snippet would imply.

However, when I wanted to find an unfriendly contributing policy, I immediately thought of haskell-src-exts. I do genuinely find the document, as a whole, quite unwelcoming. I appreciate that languages sound different to native speakers, and it didn't stop me contributing, but it did give me pause. Whether a document is friendly or not is a feeling, and so by explaining why I have that feeling