This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connectionUrl :: Monad m => ReaderT m Config B.ByteString | |
-- withConnection | |
-- :: (Database.PostgreSQL.Simple.Internal.Connection -> IO c) | |
-- -> ReaderT Config IO c | |
withConnection f = do | |
url <- connectionUrl | |
liftIO $ bracket (connectPostgreSQL url) close f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Concurrent.Chan (Chan, newChan) | |
import qualified Data.Map as M | |
import Control.Concurrent.STM | |
import Control.Monad.Trans (MonadIO, liftIO) | |
import GHC.Conc (unsafeIOToSTM) | |
type Id = Integer | |
getOrCreateChannel :: (MonadIO m) => Id -> TVar (M.Map Id (Chan a)) -> m (Chan a) | |
getOrCreateChannel cid t = liftIO . atomically $ do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
module Forall where | |
import Control.Applicative | |
import Data.Aeson | |
import Control.Monad | |
data Bar = Bar Int | |
data Baz = Baz Int Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Aeson | |
import Data.Attoparsec | |
import qualified Data.Enumerator as E | |
import qualified Data.Enumerator.Binary as Eb | |
import qualified Data.Enumerator.List as El | |
import qualified Data.ByteString as BS | |
byteLines :: Monad m => E.Enumeratee BS.ByteString BS.ByteString m b | |
byteLines = Eb.splitWhen (== 10) -- 10 is LF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#line 1 "ParseInt64.rl" | |
#include <HsFFI.h> | |
#line 7 "ParseInt64.c" | |
static const int ParseInt64_start = 1; | |
static const int ParseInt64_first_final = 3; | |
static const int ParseInt64_error = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad (liftM) | |
import Data.Complex (Complex(..)) | |
import Data.List (foldl, lookup, words) | |
import Text.Printf (printf) | |
data Direction = N | E | S | W deriving (Show,Read,Eq) | |
data Instruction = R | L | M deriving (Show,Read) | |
data Vector = Vector (Complex Double) (Complex Double) | |
-- map directions to Complex numbers |