Skip to content

Instantly share code, notes, and snippets.

View ndmitchell's full-sized avatar

Neil Mitchell ndmitchell

View GitHub Profile
@ndmitchell
ndmitchell / Rec.hs
Created May 11, 2018 18:43
4-file GHC bug
{-# LANGUAGE DisambiguateRecordFields #-}
import Rec3
import Rec2
bug = AnDouble{an=1}
@ndmitchell
ndmitchell / Monad.hs
Created March 24, 2018 21:45
Shake Action as a GADT
{-# LANGUAGE CPP #-}
{-# LANGUAGE GeneralizedNewtypeDeriving, GADTs, DeriveFunctor, ScopedTypeVariables, BangPatterns #-}
module Development.Shake.Internal.Core.Monad(
RAW, Capture, runRAW,
getRO, getRW, getsRO, getsRW, putRW, modifyRW,
catchRAW, tryRAW, throwRAW,
unmodifyRW, captureRAW,
) where
-- To use:
-- Place this file in compiler/.ghci
-- stack exec --stack-yaml=../hadrian/stack.yaml -- ghci -package-db=../_build/stage0/bootstrapping.conf
:set -ibackpack
:set -ibasicTypes
:set -icmm
:set -icodeGen
:set -icoreSyn
:set -ideSugar
@ndmitchell
ndmitchell / Lib.c
Last active May 2, 2019 14:33
memchr vs strchr
#include <stddef.h>
// From http://clc-wiki.net/wiki/strchr
char *strchr_c(const char *s, int c)
{
while (*s != (char)c)
if (!*s++)
return 0;
return (char *)s;
}
@ndmitchell
ndmitchell / bug.hs
Created November 16, 2017 21:41
Exceptions from "wrapper" functions
-- ghc bug.hs c.c && bug
module Main(main) where
import Control.Concurrent
import Control.Monad
import Foreign.C
import Foreign.Ptr
foreign import ccall apply :: FunPtr (CString -> IO CString) -> CString -> IO CString
@ndmitchell
ndmitchell / hse-atom.hs
Last active November 15, 2017 22:28
HSE analysis of atoms
{-# LANGUAGE ScopedTypeVariables #-}
-- Note that 1 vs -1 is one of the few things that matters!!!
import Language.Haskell.Exts
import Language.Haskell.Exts.Util
import Data.Data
import Control.Monad
import Data.List
@ndmitchell
ndmitchell / Binary.hs
Last active August 10, 2021 21:42
Binary existentials
{-# LANGUAGE StaticPointers #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleInstances #-}
import Data.Binary
import System.IO.Unsafe
import GHC.StaticPtr
@ndmitchell
ndmitchell / Binary.hs
Created August 31, 2017 20:40
Binary serialisation of existentials
{-# LANGUAGE StaticPointers #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Binary
import Data.Typeable
import System.IO.Unsafe
import GHC.StaticPtr
@ndmitchell
ndmitchell / HSE.hs
Last active July 30, 2017 21:31
Threepenny GUI's
{-# LANGUAGE RecursiveDo #-}
module Main(main) where
import qualified Graphics.UI.Threepenny as UI
import Graphics.UI.Threepenny.Core
import Graphics.UI.Threepenny.Editors
import Data.Profunctor
import Language.Haskell.Exts
@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