Skip to content

Instantly share code, notes, and snippets.

@luite
luite / B.hs
Created September 4, 2013 23:42
demonstration of the GHC Hooks API. Compile with -dynamic if you have dynamic GHC programs. Make sure that B.hs in the same directory
{-# LANGUAGE ForeignFunctionInterface, QuasiQuotes #-}
module Main where
import Text.Blaze
import Text.Blaze.Renderer.String
import Text.Hamlet -- provided by hamlet package
foreign import ccall safe "sin" c_testImport :: Double -> IO Double
@luite
luite / install.sh
Last active December 25, 2015 23:59
cabal-src-install dependencies
#!/bin/bash
install_src_pkg() {
wget -q "http://ghcjs.github.io/packages/cabal-src/$1/$2/$1-$2.tar.gz"
tar -xzf "$1-$2.tar.gz"
cd "$1-$2"
cabal-src-install --src-only
cd ..
}
@luite
luite / interactive.hs
Last active December 24, 2015 03:29
Interactive results for interactive-diagrams
{-# LANGUAGE TypeFamilies,
MultiParamTypeClasses,
FlexibleInstances,
UndecidableInstances,
FunctionalDependencies #-}
import Control.Concurrent
import Control.Monad
import Control.Monad.Fix
@luite
luite / B.hs
Created September 10, 2013 07:27
hooks demo with the records implementation of Hooks
{-# LANGUAGE ForeignFunctionInterface, QuasiQuotes #-}
module Main where
import Text.Blaze
import Text.Blaze.Renderer.String
import Text.Hamlet -- provided by hamlet package
foreign import ccall safe "sin" c_testImport :: Double -> IO Double
@luite
luite / B.hs
Created September 7, 2013 20:26
hooks demo, using Dynamic variant of hooks patch
{-# LANGUAGE ForeignFunctionInterface, QuasiQuotes #-}
module Main where
import Text.Blaze
import Text.Blaze.Renderer.String
import Text.Hamlet -- provided by hamlet package
foreign import ccall safe "sin" c_testImport :: Double -> IO Double
@luite
luite / B.hs
Created August 22, 2013 20:04
How to use RunQuasiQuoterHook
{-# LANGUAGE QuasiQuotes #-}
module B where
import Text.Hamlet
import Text.Blaze
f :: Markup
f = [shamlet| <h1>Hello
<p>world
@luite
luite / ghcLoad.hs
Created June 12, 2013 11:58
load files quickly
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Control.Applicative
import Control.Concurrent
import Control.Monad
import Data.Time.Clock
import Diagrams.Prelude
import Diagrams.Backend.Cairo
import System.Posix.Process
@luite
luite / nqueens.js
Created October 8, 2012 01:43
n-queens 12
/*
StgRec [
( Main.listAppend,StgRhsClosure CostCentreStack StgBinderInfo [] ReEntrant SRT [ds,l2]
( StgCase
( StgApp ds []
)
UniqSet UniqSet wild SRT Alg Main.List [
( DataAlt Main.Cons,[a,l1],[True,True],StgLet
( StgNonRec sat_s1Dy
( StgRhsClosure CostCentreStack StgBinderInfo [l1,l2] Updatable SRT []
@luite
luite / nqueens12.js
Created September 24, 2012 22:09
n-queens on 12x12, crashes v8 here or gives wrong result (exception)
/*
StgRec [
( Main.listAppend,StgRhsClosure CostCentreStack StgBinderInfo [] ReEntrant SRT [ds,l2]
( StgCase
( StgApp ds []
)
UniqSet UniqSet wild SRT Alg Main.List [
( DataAlt Main.Cons,[a,l1],[True,True],StgLet
( StgNonRec sat_s1OT
( StgRhsClosure CostCentreStack StgBinderInfo [l1,l2] Updatable SRT []
@luite
luite / fib35.js
Created September 24, 2012 22:06
calculates 35th fibonacci number
/*
StgRec [
( Fibs.$wfib,StgRhsClosure CostCentreStack StgBinderInfo [] ReEntrant SRT [ww]
( StgCase
( StgApp ww []
)
UniqSet UniqSet ds SRT Prim GHC.Prim.Int# [
( DEFAULT,[],[],StgCase
( StgOpApp
( StgPrimOp IntSubOp