Skip to content

Instantly share code, notes, and snippets.

@paul-r-ml
paul-r-ml / Main.hs
Created December 4, 2011 17:20
Concurrent HDBC with resource-pool
module Main where
import Control.Monad (forever)
import Control.Concurrent (forkIO)
import Control.Concurrent.Chan
import Data.Pool
import Database.HDBC
import Database.HDBC.PostgreSQL
@paul-r-ml
paul-r-ml / reader-applicative-monadic.rb
Created December 7, 2011 16:40
simple reader monad
require 'funkr/types'
class Reader
def initialize(func); @func = func; end
def run(env); @func.call(env); end
# Pour l'usage du foncteur applicatif
def map(&block); reader{|env| block.call(run(env))}; end
def self.pure(v); reader{|_env| v}; end
def apply(to); reader{|env| run(env).call(to.run(env))}; end
@paul-r-ml
paul-r-ml / SafeListExperiments.hs
Created February 2, 2012 16:05
Haskell GADTs baby steps
{-# LANGUAGE GADTs , KindSignatures #-}
data Zero
data Succ a
data List :: * -> * -> * where
Nil :: List Zero a
Cons :: a -> List t a -> List (Succ t) a
data AnyList :: * -> * where
@paul-r-ml
paul-r-ml / applicative-parse.hs
Created March 15, 2012 19:10
basic applicative parser
module Parser1 where
-- | On importe uniquement quelques types de base, quelques fonctions
-- et quelques opérateurs habituels
import Prelude ( String, Maybe(..), Char, Int, Show(..),
fmap, fst, read,
splitAt, length, span, elem,
($), (.), (==), (+), (*) )