packages feed

sql-simple-postgresql (empty) → 0.1.0.0

raw patch · 4 files changed

+132/−0 lines, 4 filesdep +basedep +data-default-classdep +postgresql-simplesetup-changed

Dependencies added: base, data-default-class, postgresql-simple, sql-simple, tagged, text

Files

+ Database/Sql/Simple/PostgreSQL.hs view
@@ -0,0 +1,82 @@+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE FlexibleInstances #-}++module Database.Sql.Simple.PostgreSQL+    ( PostgreSQL+    , ConnectInfo(..)+    , postgreSQL+    , psql+    , module Data.Default.Class+    ) where++import Control.Applicative+import Control.Monad+import qualified Data.Text.Encoding as T+import Data.Typeable+import Data.Proxy+import Data.Word+import Database.Sql.Simple.Internal+import qualified Database.PostgreSQL.Simple as PSql+import qualified Database.PostgreSQL.Simple.ToRow as PSql+import qualified Database.PostgreSQL.Simple.FromRow as PSql+import qualified Database.PostgreSQL.Simple.ToField as PSql+import qualified Database.PostgreSQL.Simple.FromField as PSql+import qualified Database.PostgreSQL.Simple.Types as PSql+import Data.Default.Class++data PostgreSQL = PostgreSQL PSql.Connection+    deriving Typeable++instance PSql.ToField a => PSql.ToRow (Only a) where+    toRow (Only v) = PSql.toRow $ PSql.Only v++instance PSql.FromField a => PSql.FromRow (Only a) where+    fromRow = Only . PSql.fromOnly <$> PSql.fromRow++instance (PSql.ToRow a, PSql.ToRow b) => PSql.ToRow (a :. b) where+    toRow (a :. b) = PSql.toRow $ a PSql.:. b++instance (PSql.FromRow a, PSql.FromRow b) => PSql.FromRow (a :. b) where+    fromRow = (\(a PSql.:. b) -> a :. b) <$> PSql.fromRow++instance Backend PostgreSQL where+    data ConnectInfo PostgreSQL = ConnectInfo+        { connectHost     :: String+        , connectPort     :: Word16+        , connectUser     :: String+        , connectPassword :: String+        , connectDatabase :: String+        } deriving (Eq, Read, Show)+    type ToRow   PostgreSQL = PSql.ToRow+    type FromRow PostgreSQL = PSql.FromRow++    connect (ConnectInfo h p u w d) =+        PostgreSQL <$> PSql.connect (PSql.ConnectInfo h p u w d)+    close   (PostgreSQL      c) = PSql.close c++    execute  (PostgreSQL c) t q = void . Sql $ PSql.execute  c (psqlQuery t) q+    execute_ (PostgreSQL c) t   = void . Sql $ PSql.execute_ c (psqlQuery t)++    query    (PostgreSQL c) t q = Sql $ PSql.query  c (psqlQuery t) q+    query_   (PostgreSQL c) t   = Sql $ PSql.query_ c (psqlQuery t)++    begin    (PostgreSQL c) = Sql $ PSql.begin c+    commit   (PostgreSQL c) = Sql $ PSql.commit c+    rollback (PostgreSQL c) = Sql $ PSql.rollback c++instance Default (ConnectInfo PostgreSQL) where+    def = ConnectInfo h p u w d+      where+        PSql.ConnectInfo h p u w d = PSql.defaultConnectInfo++psqlQuery :: Query -> PSql.Query+psqlQuery = PSql.Query . T.encodeUtf8 . getQuery (typeOf (undefined :: PostgreSQL))++postgreSQL :: Proxy '[PostgreSQL]+postgreSQL = Proxy++psql :: Proxy '[PostgreSQL]+psql = postgreSQL
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2014 Hirotomo Moriwaki++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ sql-simple-postgresql.cabal view
@@ -0,0 +1,28 @@+name:                sql-simple-postgresql+version:             0.1.0.0+synopsis:            postgresql backend for sql-simple+-- description:         +license:             MIT+license-file:        LICENSE+author:              HirotomoMoriwaki<philopon.dependence@gmail.com>+maintainer:          HirotomoMoriwaki<philopon.dependence@gmail.com>+Homepage:            https://github.com/philopon/apiary+Bug-reports:         https://github.com/philopon/apiary/issues+copyright:           (c) 2014 Hirotomo Moriwaki+category:            Database+build-type:          Simple+cabal-version:       >=1.10++library+  exposed-modules:     Database.Sql.Simple.PostgreSQL+  build-depends:       base                 >=4.6 && <4.8+                     , text                 >=1.1 && <1.2+                     , sql-simple           >=0.1 && <0.2+                     , postgresql-simple    >=0.4 && <0.5+                     , data-default-class   >=0.0 && <0.1++  if impl(ghc < 7.8)+    build-depends:     tagged               >=0.7 && <0.8++  ghc-options:         -Wall -O2+  default-language:    Haskell2010