packages feed

monetdb-mapi 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+28/−20 lines, 2 filesdep ~base

Dependency ranges changed: base

Files

monetdb-mapi.cabal view
@@ -1,7 +1,7 @@ name:                monetdb-mapi-version:             0.1.0.0+version:             0.1.0.1 synopsis:            Mid-level bindings for the MonetDB API (mapi)--- description:         +description:         This library provides a convenient API to work with MonetDB. license:             BSD3 license-file:        LICENSE author:              Moritz Bruder@@ -20,7 +20,7 @@   exposed-modules:     Database.MonetDB.Mapi   -- other-modules:          -- other-extensions:    -  build-depends:       base >=4.8 && <4.10,+  build-depends:       base >=4.8 && <4.12,                        bindings-monetdb-mapi ==0.1.*    hs-source-dirs:      src
src/Database/MonetDB/Mapi.hs view
@@ -6,13 +6,14 @@     , ErrorType(..)      -- * Connection parameters+    , Database     , Lang(..)     , ConInfo(..)     , emptyConInfo     , defConInfo      -- * Connection handling-    , Connection(..)+    , Connection     , connect     , disconnect     , withConnection@@ -32,26 +33,29 @@ import qualified Bindings.MonetDB.Mapi as B import qualified Control.Exception     as E +-- | Error types that may occur within MonetDB.+data ErrorType+    = Default String+    | Timeout+    | Server String+    deriving Show+ -- | Some IO actions might throw 'MapiError'.-data MapiError = MapiError-               { errorType    :: ErrorType-               }-               deriving Show+newtype MapiError+    = MapiError+    { errorType :: ErrorType+    } deriving Show  instance E.Exception MapiError where     toException                       = E.SomeException     fromException (E.SomeException e) = cast e -data ErrorType = Default String-               | Timeout-               | Server String-               deriving Show- -- | The language to be used for a connection.-data Lang = Sql-          | Mil-          | Mal-          | XQuery+data Lang+    = Sql+    | Mil+    | Mal+    | XQuery  fromLang :: Lang -> String fromLang l = case l of@@ -72,7 +76,6 @@     if e == B.cMERROR     then do         cstr <- B.mapi_error_str mapi-        print cstr         s <- peekCString cstr         E.throwIO $ MapiError $ Default s     else when (e == B.cMTIMEOUT) $ E.throwIO $ MapiError Timeout@@ -134,10 +137,14 @@ -- [["42", "23"]] -- withConnection :: ConInfo -> Lang -> (Connection -> IO a) -> IO a-withConnection ci l f = E.bracket (connect ci l) disconnect f+withConnection ci l = E.bracket (connect ci l) disconnect  --- TODO rework Result and Query, that mechanism is terrible+-- TODO rework Result and Query, that mechanism is terrible:+-- The issue here is that some components may be used multiple times, but that+-- is a type of error. A representation is required that does not allow using+-- resources several times in IO actions (e.g. inversion of control with a+-- function).  type QueryForeignPtr = ForeignPtr () @@ -195,5 +202,6 @@     r <- execute q     fetchRows r +-- | Run a query and ignore the result. quickQuery_ :: Connection -> String -> IO () quickQuery_ c s = query c s >>= void . execute