Browse files

Use mtl and support ReaderT CPool m directly

  • Loading branch information...
1 parent c7a3d33 commit 43620c3f2d9aba049da210a47dc2ef40c8e8db49 @ozataman ozataman committed May 23, 2012
Showing with 8 additions and 10 deletions.
  1. +2 −2 cassy.cabal
  2. +6 −7 src/Database/Cassandra/Basic.hs
  3. +0 −1 src/Database/Cassandra/Pool.hs
View
4 cassy.cabal
@@ -1,5 +1,5 @@
Name: cassy
-Version: 0.3.2.2
+Version: 0.3.3
Synopsis: A high level driver for the Cassandra datastore
License: BSD3
License-file: LICENSE
@@ -62,7 +62,7 @@ Library
, containers
, network
, time
- , transformers
+ , mtl
, stm
, syb
, text
View
13 src/Database/Cassandra/Basic.hs
@@ -2,6 +2,7 @@
{-# LANGUAGE PatternGuards, NamedFieldPuns, RecordWildCards #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleInstances #-}
module Database.Cassandra.Basic
@@ -63,8 +64,7 @@ module Database.Cassandra.Basic
import Control.Applicative
import Control.Exception
import Control.Monad
-import Control.Monad.IO.Class
-import Control.Monad.Trans.Reader
+import Control.Monad.Reader
import Data.ByteString.Lazy (ByteString)
import Data.Map (Map)
import qualified Data.Map as M
@@ -120,21 +120,20 @@ withCassandraPool f = do
-------------------------------------------------------------------------------
-newtype Cas a = Cas { unCas :: ReaderT CPool IO a }
- deriving (Functor,Applicative,Monad,MonadIO)
+type Cas a = ReaderT CPool IO a
-------------------------------------------------------------------------------
-- | Main running function when using the ad-hoc Cas monad. Just write
-- your cassandra actions within the 'Cas' monad and supply them with
-- a 'CPool' to execute.
runCas :: Cas a -> CPool -> IO a
-runCas f p = runReaderT (unCas f) p
+runCas = runReaderT
-------------------------------------------------------------------------------
-instance MonadCassandra Cas where
- getCassandraPool = Cas ask
+instance (MonadIO m) => MonadCassandra (ReaderT CPool m) where
+ getCassandraPool = ask
------------------------------------------------------------------------------
View
1 src/Database/Cassandra/Pool.hs
@@ -17,7 +17,6 @@ import Control.Applicative ((<$>))
import Control.Concurrent.STM
import Control.Exception (SomeException, catch, onException)
import Control.Monad (forM_, forever, join, liftM2, unless, when)
-import Control.Monad.IO.Class (liftIO)
import Data.ByteString (ByteString)
import Data.List (partition)
import "resource-pool" Data.Pool

0 comments on commit 43620c3

Please sign in to comment.