diff --git a/README.md b/README.md index 6135f64..9cfdda0 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ main = do filepath <- execParser cmdParser let object = pack $ takeBaseName filepath - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do -- Make a bucket; catch bucket already exists exception if thrown. catchIf (== BucketAlreadyOwnedByYou) (makeBucket bucket Nothing) ignoreMinioErr diff --git a/docs/API.md b/docs/API.md index fc1a430..fba09c0 100644 --- a/docs/API.md +++ b/docs/API.md @@ -117,7 +117,7 @@ performs connection pooling, bucket location caching (if enabled) and error handling. The `runMinio` function performs the provided action in the `Minio` -monad and returns a `ResourceT IO (Either MinioErr a)` value: +monad and returns a `IO (Either MinioErr a)` value: ``` haskell {-# Language OverloadedStrings #-} @@ -126,7 +126,7 @@ import Network.Minio main :: IO () main = do - result <- runResourceT $ runMinio def $ do + result <- runMinio def $ do buckets <- listBuckets return $ length buckets @@ -139,9 +139,6 @@ The above performs a `listBuckets` operation and returns the number of buckets in the server. If there were any errors, they will be returned as values of type `MinioErr` as a `Left` value. -`runResourceT` takes a value from `ResourceT IO a` to `IO a`. It takes -care of running finalizers to free resources. - ## 2. Bucket operations @@ -185,7 +182,7 @@ __Example__ main :: IO () main = do - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do makeBucket bucketName (Just "us-east-1") case res of @@ -216,7 +213,7 @@ __Example__ main :: IO () main = do - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do removeBucket "mybucket" case res of @@ -272,7 +269,7 @@ main = do -- Performs a recursive listing of all objects under bucket "test" -- on play.minio.io. - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do listObjects bucket Nothing True $$ sinkList print res @@ -323,7 +320,7 @@ main = do -- Performs a recursive listing of all incompletely uploaded objects -- under bucket "test" on play.minio.io. - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do listIncompleteUploads bucket Nothing True $$ sinkList print res @@ -372,7 +369,7 @@ main = do -- Lists the parts in an incompletely uploaded object identified by -- bucket, object and upload ID. - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do source <- getObject bucket object source $$+- sinkLbs @@ -413,7 +410,7 @@ main = do object = "myobject" kb15 = 15 * 1024 - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do putObject bucket object (CC.repeat "a") (Just kb15) case res of @@ -459,7 +456,7 @@ main = do object = "my-object" localFile = "/etc/lsb-release" - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do src <- fGetObject bucket object localFile (src $$+- sinkLbs) @@ -497,7 +494,7 @@ main = do object = "myobject" localFile = "/etc/lsb-release" - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do fPutObject bucket object localFile case res of @@ -545,7 +542,7 @@ main = do object = "myobject" srcObject = "/mybucket/srcObject" - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do copyObject bucket object def { cpSource = srcObject } case res of @@ -579,7 +576,7 @@ main = do bucket = "mybucket" object = "myobject" - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do removeObject bucket object case res of diff --git a/examples/BucketExists.hs b/examples/BucketExists.hs index b5a1ca8..8c1fa0a 100755 --- a/examples/BucketExists.hs +++ b/examples/BucketExists.hs @@ -34,10 +34,10 @@ main :: IO () main = do let bucket = "missingbucket" - res1 <- runResourceT $ runMinio minioPlayCI $ do + res1 <- runMinio minioPlayCI $ do foundBucket <- bucketExists bucket liftIO $ putStrLn $ "Does " ++ show bucket ++ " exist? - " ++ show foundBucket case res1 of - Left e -> putStrLn $ "bucketExists failed." ++ (show e) + Left e -> putStrLn $ "bucketExists failed." ++ show e Right () -> return () diff --git a/examples/CopyObject.hs b/examples/CopyObject.hs index a4ee728..b91b88d 100755 --- a/examples/CopyObject.hs +++ b/examples/CopyObject.hs @@ -42,7 +42,7 @@ main = do objectCopy = "obj-copy" localFile = "/etc/lsb-release" - res1 <- runResourceT $ runMinio minioPlayCI $ do + res1 <- runMinio minioPlayCI $ do -- 1. Make a bucket; Catch BucketAlreadyOwnedByYou exception. catchIf (== BucketAlreadyOwnedByYou) (makeBucket bucket Nothing) ignoreMinioErr diff --git a/examples/FileUploader.hs b/examples/FileUploader.hs index 988b3df..89dfa91 100755 --- a/examples/FileUploader.hs +++ b/examples/FileUploader.hs @@ -61,7 +61,7 @@ main = do filepath <- execParser cmdParser let object = pack $ takeBaseName filepath - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do -- Make a bucket; catch bucket already exists exception if thrown. catchIf (== BucketAlreadyOwnedByYou) (makeBucket bucket Nothing) ignoreMinioErr diff --git a/examples/GetObject.hs b/examples/GetObject.hs index 4aeae57..4793f56 100755 --- a/examples/GetObject.hs +++ b/examples/GetObject.hs @@ -36,7 +36,7 @@ main = do let bucket = "my-bucket" object = "my-object" - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ do src <- getObject bucket object (src $$+- sinkLbs) diff --git a/examples/HeadObject.hs b/examples/HeadObject.hs index f0f7b08..1f4b04b 100755 --- a/examples/HeadObject.hs +++ b/examples/HeadObject.hs @@ -35,9 +35,9 @@ main = do let bucket = "test" object = "passwd" - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ headObject bucket object case res of - Left e -> putStrLn $ "headObject failed." ++ (show e) - Right objInfo -> putStrLn $ "headObject succeeded." ++ (show objInfo) + Left e -> putStrLn $ "headObject failed." ++ show e + Right objInfo -> putStrLn $ "headObject succeeded." ++ show objInfo diff --git a/examples/ListBuckets.hs b/examples/ListBuckets.hs index 731edd8..ec2fba7 100755 --- a/examples/ListBuckets.hs +++ b/examples/ListBuckets.hs @@ -34,8 +34,8 @@ import Prelude -- region of the first bucket returned. main :: IO () main = do - firstRegionE <- runResourceT $ runMinio minioPlayCI $ do + firstRegionE <- runMinio minioPlayCI $ do buckets <- listBuckets - liftIO $ print $ "Top 5 buckets: " ++ (show $ take 5 buckets) + liftIO $ print $ "Top 5 buckets: " ++ show (take 5 buckets) getLocation $ biName $ head buckets print firstRegionE diff --git a/examples/ListIncompleteUploads.hs b/examples/ListIncompleteUploads.hs index 491fecd..612601f 100755 --- a/examples/ListIncompleteUploads.hs +++ b/examples/ListIncompleteUploads.hs @@ -38,7 +38,7 @@ main = do -- Performs a recursive listing of incomplete uploads under bucket "test" -- on a local minio server. - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ listIncompleteUploads bucket Nothing True $$ sinkList print res diff --git a/examples/ListObjects.hs b/examples/ListObjects.hs index c861911..b852a31 100755 --- a/examples/ListObjects.hs +++ b/examples/ListObjects.hs @@ -39,7 +39,7 @@ main = do -- Performs a recursive listing of all objects under bucket "test" -- on play.minio.io. - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ listObjects bucket Nothing True C.$$ CC.sinkList print res diff --git a/examples/Makebucket.hs b/examples/Makebucket.hs index 75188c0..9728219 100755 --- a/examples/Makebucket.hs +++ b/examples/Makebucket.hs @@ -34,7 +34,7 @@ main :: IO () main = do let bucket = "my-bucket" - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ -- N B the region provided for makeBucket is optional. makeBucket bucket (Just "us-east-1") print res diff --git a/examples/PutObject.hs b/examples/PutObject.hs index 3c5ba4d..4b086f4 100755 --- a/examples/PutObject.hs +++ b/examples/PutObject.hs @@ -39,16 +39,16 @@ main = do kb15 = 15 * 1024 -- Eg 1. Upload a stream of repeating "a" using putObject. - res1 <- runResourceT $ runMinio minioPlayCI $ do + res1 <- runMinio minioPlayCI $ putObject bucket object (CC.repeat "a") (Just kb15) case res1 of - Left e -> putStrLn $ "putObject failed." ++ (show e) + Left e -> putStrLn $ "putObject failed." ++ show e Right () -> putStrLn "putObject succeeded." -- Eg 2. Upload a file using fPutObject. - res2 <- runResourceT $ runMinio minioPlayCI $ do + res2 <- runMinio minioPlayCI $ fPutObject bucket object localFile case res2 of - Left e -> putStrLn $ "fPutObject failed." ++ (show e) + Left e -> putStrLn $ "fPutObject failed." ++ show e Right () -> putStrLn "fPutObject succeeded." diff --git a/examples/RemoveObject.hs b/examples/RemoveObject.hs index b5e6ffc..5661f14 100755 --- a/examples/RemoveObject.hs +++ b/examples/RemoveObject.hs @@ -28,7 +28,7 @@ main = do bucket = "mybucket" object = "myobject" - res <- runResourceT $ runMinio minioPlayCI $ do + res <- runMinio minioPlayCI $ removeObject bucket object case res of diff --git a/examples/Removebucket.hs b/examples/Removebucket.hs index 51794a7..f298196 100755 --- a/examples/Removebucket.hs +++ b/examples/Removebucket.hs @@ -34,6 +34,5 @@ main :: IO () main = do let bucket = "my-bucket" - res <- runResourceT $ runMinio minioPlayCI $ do - removeBucket bucket + res <- runMinio minioPlayCI $ removeBucket bucket print res diff --git a/src/Network/Minio.hs b/src/Network/Minio.hs index 5c1a94c..77278dd 100644 --- a/src/Network/Minio.hs +++ b/src/Network/Minio.hs @@ -25,7 +25,6 @@ module Network.Minio , Minio , runMinio - , runResourceT , def -- * Error handling @@ -77,7 +76,6 @@ module Network.Minio This module exports the high-level Minio API for object storage. -} -import Control.Monad.Trans.Resource (runResourceT) import qualified Data.Conduit as C import qualified Data.Conduit.Binary as CB import Data.Default (def) diff --git a/src/Network/Minio/Data.hs b/src/Network/Minio/Data.hs index d4ea999..17924b4 100644 --- a/src/Network/Minio/Data.hs +++ b/src/Network/Minio/Data.hs @@ -342,10 +342,10 @@ connect ci = do return $ MinioConn ci mgr -- | Run the Minio action and return the result or an error. -runMinio :: ConnectInfo -> Minio a -> ResourceT IO (Either MinioErr a) +runMinio :: ConnectInfo -> Minio a -> IO (Either MinioErr a) runMinio ci m = do conn <- liftIO $ connect ci - flip evalStateT Map.empty . flip runReaderT conn . unMinio $ + runResourceT . flip evalStateT Map.empty . flip runReaderT conn . unMinio $ fmap Right m `MC.catches` [ MC.Handler handlerServiceErr , MC.Handler handlerHE diff --git a/test/LiveServer.hs b/test/LiveServer.hs index f74d7ab..0417a6c 100644 --- a/test/LiveServer.hs +++ b/test/LiveServer.hs @@ -83,7 +83,7 @@ funTestWithBucket t minioTest = testCaseSteps t $ \step -> do let b = T.concat [funTestBucketPrefix, T.pack bktSuffix] liftStep = liftIO . step connInfo <- maybe minioPlayCI (const def) <$> lookupEnv "MINIO_LOCAL" - ret <- runResourceT $ runMinio connInfo $ do + ret <- runMinio connInfo $ do liftStep $ "Creating bucket for test - " ++ t foundBucket <- bucketExists b liftIO $ foundBucket @?= False