Skip to content

Instantly share code, notes, and snippets.

@maoe
maoe / iteratee-pipes.hs
Last active August 29, 2015 14:14
Convert between pipes and iteratee
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -Wall #-}
import Control.Exception
import Control.Monad
import System.IO
import Control.Monad.Except
import Pipes.Core ((+>>))
import qualified Data.Iteratee as I
import qualified Data.Iteratee.Char as I
@maoe
maoe / UniversallyQuantifiedConstraints.hs
Created December 29, 2014 14:32
Universally quantified constraints
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
module ForallConstraints where
import Data.Monoid
import Data.Constraint
import Data.Constraint.Forall
data Box t where
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-} -- GHC 7.6 needs this but GHC 7.8 does not
module Undecidable where
class a ~ a => C a
instance a ~ a => C a
diff --git a/src/Control/Retry.hs b/src/Control/Retry.hs
index 64bf19f..36daf84 100644
--- a/src/Control/Retry.hs
+++ b/src/Control/Retry.hs
@@ -4,6 +4,7 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE ViewPatterns #-}
@maoe
maoe / memory-leak.hs
Last active August 29, 2015 14:07
Reproduce the memory leak issue in InfluxDB
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
import Control.Concurrent
import Control.Exception
import Control.Monad
import Data.Function
import Data.Monoid
import Data.Text
import System.Timeout
@maoe
maoe / hackagedocs
Last active August 29, 2015 14:07 — forked from Fuuzetsu/hackagedocs
#!/bin/bash
cabal configure && cabal build && cabal haddock --hyperlink-source \
--html-location='http://hackage.haskell.org/package/$pkg/docs' \
--contents-location='http://hackage.haskell.org/package/$pkg'
S=$?
if [ "${S}" -eq "0" ]; then
cd "dist/doc/html"
DDIR="${1}-${2}-docs"
cp -r "${1}" "${DDIR}" && tar -c -v -z -Hustar -f "${DDIR}.tar.gz" "${DDIR}"
CS=$?
@maoe
maoe / World.hs
Created September 11, 2014 03:26
query-tooltip signal isn't emitted in gtk2hs
-- A simple program to demonstrate Gtk2Hs.
module Main (Main.main) where
import Graphics.UI.Gtk
main :: IO ()
main = do
initGUI
-- Create a new window
window <- windowNew
[maoe@maoe:~/src/bindings-portaudio/example on master]
% brew install portaudio
Warning: portaudio-19.20140130 already installed
[maoe@maoe:~/src/bindings-portaudio/example on master]
% ./.cabal-sandbox/bin/example-portaudio 44100 1024
Initialization: 0
Available APIs:
Opening the default stream: -9985
example-portaudio: user error (Failed.)
@maoe
maoe / DynMap.hs
Last active August 29, 2015 14:04
{-# OPTIONS_GHC -O2 -fobject-code #-}
module DynMap where
import Control.Applicative
import Control.Monad (join)
import Control.Seq
import Data.Map (Map)
import Data.Traversable (Traversable)
import qualified Data.Map as Map
import qualified Data.Traversable as T
@maoe
maoe / PerformAsync.hs
Created July 10, 2014 09:45
performAsync
perform
:: (a -> IO b)
-> Event a
-> SignalGen (Event b)
perform f event = generatorE $ execute . f <$> event
performSync :: Event (IO a) -> SignalGen (Event a)
performSync = perform id
-- | Perform IO actions asynchronously in separate threads.