diff --git a/postgresql-libpq.cabal b/postgresql-libpq.cabal index abb774b..b17d1dd 100644 --- a/postgresql-libpq.cabal +++ b/postgresql-libpq.cabal @@ -18,11 +18,22 @@ Copyright: (c) 2010 Grant Monroe (c) 2011 Leon P Smith Category: Database Build-type: Custom --- Extra-source-files: + +-- Unfortunately cabal sdist isn't smart enough to catch all hs-source-dirs +-- whether or not they are behind a conditional +Extra-source-files: unix/Database/PostgreSQL/LibPQ/*.hs + windows/Database/PostgreSQL/LibPQ/*.hs + Cabal-version: >=1.8 Library hs-source-dirs: src + if os(windows) + hs-source-dirs: windows + else + hs-source-dirs: unix + Exposed-modules: Database.PostgreSQL.LibPQ + Database.PostgreSQL.LibPQ.GHC Build-depends: base >= 4 && < 5 , bytestring diff --git a/unix/Database/PostgreSQL/LibPQ/GHC.hs b/unix/Database/PostgreSQL/LibPQ/GHC.hs new file mode 100644 index 0000000..3b31d58 --- /dev/null +++ b/unix/Database/PostgreSQL/LibPQ/GHC.hs @@ -0,0 +1,38 @@ +------------------------------------------------------------------------------ +-- | +-- Module: Database.PostgreSQL.LibPQ.GHC +-- Copyright: (c) 2013 Leon P Smith +-- License: BSD3 +-- Maintainer: Leon P Smith +-- Stability: experimental +-- +-- On Unix, this re-implements some of blocking libpq functions in terms of +-- on-blocking libpq operations and GHC's IO manager. This allows +-- these operations to be interrupted by asynchronous exceptions, and means +-- that GHC's runtime is responsible for handling the concurrency instead +-- of the OS kernel. +-- +-- This module also re-exports the rest of libpq for convenience's sake. +-- Thus taking advantage of these features should be as simple as importing +-- @LibPQ.GHC@ instead of @LibPQ@. +-- +-- On Windows, this just re-exports the vanilla libpq bindings, due to +-- the lack of a satisfactory IO manager on that platform. +-- +------------------------------------------------------------------------------ + +module Database.PostgreSQL.LibPQ.GHC + ( module Database.PostgreSQL.LibPQ + , exec + , connectdb + ) where + +import Database.PostgreSQL.LibPQ hiding (exec, connectdb) +import qualified Data.ByteString as B +import qualified Database.PostgreSQL.LibPQ as LibPQ + +exec :: Connection -> B.ByteString -> IO (Maybe Result) +exec = LibPQ.exec + +connectdb :: B.ByteString -> IO Connection +connectdb = LibPQ.connectdb diff --git a/windows/Database/PostgreSQL/LibPQ/GHC.hs b/windows/Database/PostgreSQL/LibPQ/GHC.hs new file mode 100644 index 0000000..c47dbc8 --- /dev/null +++ b/windows/Database/PostgreSQL/LibPQ/GHC.hs @@ -0,0 +1,28 @@ +------------------------------------------------------------------------------ +-- | +-- Module: Database.PostgreSQL.LibPQ.GHC +-- Copyright: (c) 2013 Leon P Smith +-- License: BSD3 +-- Maintainer: Leon P Smith +-- Stability: experimental +-- +-- On Unix, this re-implements some of blocking libpq functions in terms of +-- on-blocking libpq operations and GHC's IO manager. This allows +-- these operations to be interrupted by asynchronous exceptions, and means +-- that GHC's runtime is responsible for handling the concurrency instead +-- of the OS kernel. +-- +-- This module also re-exports the rest of libpq for convenience's sake. +-- Thus taking advantage of these features should be as simple as importing +-- @LibPQ.GHC@ instead of @LibPQ@. +-- +-- On Windows, this just re-exports the vanilla libpq bindings, due to +-- the lack of a satisfactory IO manager on that platform. +-- +------------------------------------------------------------------------------ + +module Database.PostgreSQL.LibPQ.GHC + ( module Database.PostgreSQL.LibPQ + ) where + +import Database.PostgreSQL.LibPQ