Skip to content

Instantly share code, notes, and snippets.

Haskell DB Library Comparison

We will be comparing the following DB libraries:

  • HRR
  • Opaleye
  • Persistent + Esqueleto
  • Groundhog
  • postgresql-simple (and postgresql-transactional)
@cdepillabout
cdepillabout / example.hs
Last active August 29, 2015 14:24
sample for using stack to make a .hs executable and run it from the command line
#!/usr/bin/env stack
-- stack --resolver=nightly-2015-07-08 runghc --package=shelly
-- The ExtendedDefaultRules extension gives us an experience similar to
-- @ghci@. Raw values (1 and 10 below) that implement the 'Num' type
-- class will be defaulted to 'Int' (specified with the @default@
-- command below). Raw values (all strings) that implement the
-- 'IsString' typeclass will be defaulted to Text (also specified
-- with the @default@ command below).
--
@cdepillabout
cdepillabout / .gitignore
Last active August 29, 2015 14:23
notes on some of the difficult concepts used in servant (to be expanded into blog post)
dist
cabal-dev
*.o
*.hi
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
@cdepillabout
cdepillabout / comb.hs
Last active August 29, 2015 14:21
explanation of combination function in Haskell
{-# LANGUAGE ScopedTypeVariables #-}
-- | This is an explanation of a combination function written in Haskell
-- from http://rosettacode.org/wiki/Combinations#Dynamic_Programming_2
module Main where
-- | Adds a @a@ to the beginning of every list inside the list of lists.
-- However, if the list of lists is just an empty list, return an empty
-- list.
@cdepillabout
cdepillabout / rank2types-example.hs
Created October 28, 2014 15:41
short example of a place where rank2types and rankntypes are necessary
{-# LANGUAGE Rank2Types #-}
-- This is a small example of where you need to use Rank2Types (or
-- RankNTypes).
-- The 'a' type is being used polymorphically here, but when it
-- is called, it will already be bound (as either an Int or String),
-- so it cannot be used polymorphically.
--
@cdepillabout
cdepillabout / MonitorDirectory.hs
Created October 7, 2013 11:36
This is a program that will recursively monitor a directory for changed files. When it detects a changed file, it will use scp to upload that file to a server. This is nice for being able to edit files on your local computer and have them automatically synced to a remove computer as soon as you :w them in vim.
#!/usr/bin/env runhaskell -Wall
import Control.Concurrent (threadDelay, forkIO)
import Control.Concurrent.MVar
import Control.Monad (liftM, filterM)
import Data.List (isPrefixOf, (\\))
import HSH.ShellEquivs (glob)
import System.Directory (canonicalizePath, getCurrentDirectory, doesFileExist)
--import System.Environment (getArgs)
import System.FilePath ((</>))