Skip to content

Instantly share code, notes, and snippets.

@luite
luite / Root.hs
Created January 31, 2012 15:17
Hanging POST request
module Handler.Root where
import Import
-- This is a handler function for the GET request method on the RootR
-- resource pattern. All of your resource patterns are defined in
-- config/routes
--
-- The majority of the code you will write in Yesod lives in these handler
-- functions. You can spread them across multiple files if you are so
@luite
luite / InstallJs.hs
Created May 8, 2012 16:46
Build javascript files for installed packages
#!/usr/bin/env runhaskell
module Main where
import System.Process
import System.Environment
import Distribution.Simple.GHC
import Distribution.Verbosity
import Data.List (nub, isPrefixOf)
import Distribution.Simple.PackageIndex
import Distribution.InstalledPackageInfo
@luite
luite / gen2 ghcjs
Created September 24, 2012 20:33
n-queens
/*
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_s1Pj
( 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
@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 / 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 / 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 / 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 / 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 / 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