Skip to content

Instantly share code, notes, and snippets.

View ndmitchell's full-sized avatar

Neil Mitchell ndmitchell

View GitHub Profile
@ndmitchell
ndmitchell / File.hs
Created July 1, 2018 20:23
Suspending 2
suspending :: forall i k v. Ord k => Scheduler Monad i i k v
suspending rebuilder tasks target store = fst $ execState (build target) (store, Set.empty)
where
build :: k -> State (Store i k v, Set k) ()
build key = case tasks key of
Nothing -> return ()
Just task -> do
done <- gets snd
when (key `Set.notMember` done) $ do
value <- gets (getValue key . fst)
data Foo where
Bar :: Foo
Baz :: Foo
deriving Show
-- seems to be parsed as:
data Foo where {
Bar :: Foo;
Baz :: foo}
@ndmitchell
ndmitchell / Types.hs
Created August 15, 2018 21:24
Compile with no ghc libraries installed
-- Compile with:
-- ghc -hide-all-packages -fforce-recomp GHC/Types.hs -this-unit-id=ghc-prim
{-# LANGUAGE NoImplicitPrelude, MagicHash #-}
module GHC.Types where
import GHC.Prim
default ()
{-# LANGUAGE BangPatterns, RecordWildCards #-}
import Data.List.Extra
import System.Process.Extra
import System.Directory
import System.FilePath
import System.Environment
import Data.Char
import System.IO
import Debug.Trace

Allow qualified to follow module name

.. proposal-number:: Leave blank. This will be filled in when the proposal is
                     accepted.
.. trac-ticket:: Leave blank. This will eventually be filled with the Trac
                 ticket number which will track the progress of the
                 implementation of the feature.
.. implemented:: Leave blank. This will be filled in with the first GHC version which
                 implements the described feature.
@ndmitchell
ndmitchell / convert.html
Created February 18, 2019 21:37
Makefile to Shake online converter outline
<!DOCTYPE html>
<html>
<head>
<title>Shake Convertor</title>
<style type="text/css">
html, body, #root, tr {width: 100%; height: 100%;}
td {height: 100%}
#input, #output {height: 100%; width: 100%;}
#output {border: 2px solid gray;}
</style>
import B
main = print foo
@ndmitchell
ndmitchell / report.html
Created March 18, 2019 13:57
Hadrian Shake profile
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Shake report</title>
<!-- Profiling output -->
<script>
var profile =
<html>
<body>
This is a test
</body>
</html>
This file has been truncated, but you can view the full file.
Fri May 17 17:24 2019 Time and Allocation Profiling Report (Final)
demo +RTS -p -RTS
total time = 0.82 secs (824 ticks @ 1000 us, 1 processor)
total alloc = 736,329,896 bytes (excludes profiling overheads)
COST CENTRE MODULE SRC %time %alloc