Skip to content

Instantly share code, notes, and snippets.

@chrisdone
chrisdone / prana-output.txt
Created April 6, 2019 16:19
Prana output 2019-04-06
chris@precision:~/Work/chrisdone/prana/ghc-8.4/libraries/ghc-prim$ PRANA_DIR=~/Work/chrisdone/prana/prana-dir/ ./Setup build --ghc-options="-O0"
Preprocessing library for ghc-prim-0.5.2.0..
Building library for ghc-prim-0.5.2.0..
[1 of 8] Compiling GHC.Types
[2 of 8] Compiling GHC.IntWord64
[3 of 8] Compiling GHC.CString
[4 of 8] Compiling GHC.Tuple
[5 of 8] Compiling GHC.PrimopWrappers
[6 of 8] Compiling GHC.Debug
[7 of 8] Compiling GHC.Magic
@chrisdone
chrisdone / CommandLine.hs
Last active March 29, 2019 09:49
Real Haskell Program Samples
#!/usr/bin/env stack
-- stack --resolver lts-12.12 script
import Options.Applicative.Simple
import Data.Semigroup ((<>))
data Sample =
Sample
{ sampleEnable :: Bool
, sampleUrl :: String
@chrisdone
chrisdone / README.md
Last active May 2, 2024 21:40
Indexed fields exploration

Exploring possibilities with simple indexed fields

Database records and formlets and optionally populated records can be neatly all represented with the same data type when the fields are all indexed.

class Indexed i a where
  type Index i (a :: *)
@chrisdone
chrisdone / in.hs
Last active March 6, 2019 13:57
SPF output
{-# LANGUAGE OverloadedStrings #-}
import qualified Spf
main :: IO ()
main = do
serv <- Spf.newSpfServer Spf.SPF_DNS_CACHE Spf.ModerateLevel
result <-
Spf.makeSpfRequest
serv
(Spf.SpfRequest
{ Spf.spfRequestIpV4 = "130.211.0.0"
@chrisdone
chrisdone / Output STG.hs
Created March 3, 2019 19:46
Output STG from GHC
import SimplStg
import Control.Monad
import Control.Monad.Trans
import CorePrep
import CoreSyn
import CoreToStg
import CostCentre
import DynFlags
import GHC
import GHC.Paths (libdir)
@chrisdone
chrisdone / recomp.md
Last active February 25, 2019 10:01
Ideas about fast recompilation of Haskell

Detecting whether we should compile the whole module or just changed definitions within the module context:

  1. Addition of [non-name-conflicting] data types.
  2. Addition of [non-name-conflicting] constructors (sometimes, but warnings need to be generated, of course).
  3. Addition of [non-name-conflicting] functions/values.
  4. Due to let generalization, changing any definition which has a top-level type signature can let you avoid looking at anything around it.
  5. Adding an instance; if the prev code compiled, this won't break anything (normally, overlapping/incoherent instances needs thought). Also, instance heads would need to be checked for conflict against other instance heads.
  6. ???
@chrisdone
chrisdone / Trace.hs
Last active February 18, 2019 16:31
Trace all bound names in Haskell
{-# LANGUAGE TemplateHaskellQuotes #-}
{-# LANGUAGE LambdaCase, ViewPatterns #-}
-- | Trace declarations or expression bindings.
{-
tracing [d|
...
|]
-}
@chrisdone
chrisdone / PrintStgGHC8_4_3.hs
Last active December 6, 2020 18:09
Print STG in GHC 8.4.3
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
-- | Print STG in GHC 8.4.3.
module Main where
import Control.Monad.IO.Class (liftIO)
import qualified CorePrep
find ~/Work -name stack.yaml | xargs grep -o '^resolver: \([^#]*\)'
@chrisdone
chrisdone / Decoder.hs
Created February 4, 2019 10:44
Trivial binary decoder
newtype Decode a =
Decode
{ runDecode :: ByteString -> (a, ByteString)
}
deriving (Functor)
instance Applicative Decode where
(<*>) = ap
pure = return
{-# INLINE (<*>) #-}
instance Monad Decode where