packages feed

sql-simple-sqlite (empty) → 0.1.0.0

raw patch · 4 files changed

+113/−0 lines, 4 filesdep +basedep +sql-simpledep +sqlite-simplesetup-changed

Dependencies added: base, sql-simple, sqlite-simple, tagged

Files

+ Database/Sql/Simple/SQLite.hs view
@@ -0,0 +1,65 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE FlexibleInstances #-}++module Database.Sql.Simple.SQLite+    ( SQLite+    , ConnectInfo(..)+    , sqlite+    ) where++import Control.Applicative+import Data.Typeable+import Database.Sql.Simple.Internal+import qualified Database.SQLite.Simple as SQLite+import qualified Database.SQLite.Simple.ToField as SQLite+import qualified Database.SQLite.Simple.FromField as SQLite+import Data.String+import Data.Proxy++data SQLite = SQLite SQLite.Connection+    deriving Typeable++sqliteQuery :: Query -> SQLite.Query+sqliteQuery = SQLite.Query . getQuery (typeOf (undefined :: SQLite))++instance Backend SQLite where+    newtype ConnectInfo SQLite = ConnectInfo String deriving (Eq, Read, Show)+    type ToRow   SQLite = SQLite.ToRow+    type FromRow SQLite = SQLite.FromRow++    connect (ConnectInfo i) = SQLite <$> SQLite.open i+    close   (SQLite c) = SQLite.close c++    execute  (SQLite c) t q = Sql $ SQLite.execute  c (sqliteQuery t) q+    execute_ (SQLite c) t   = Sql $ SQLite.execute_ c (sqliteQuery t)++    query    (SQLite c) t q = Sql $ SQLite.query  c (sqliteQuery t) q+    query_   (SQLite c) t   = Sql $ SQLite.query_ c (sqliteQuery t)++    begin    c = execute_ c "BEGIN TRANSACTION"+    commit   c = execute_ c "COMMIT TRANSACTION"+    rollback c = execute_ c "ROLLBACK TRANSACTION"++instance IsString (ConnectInfo SQLite) where+    fromString = ConnectInfo++sqlite :: Proxy '[SQLite]+sqlite = Proxy++instance SQLite.ToField a => SQLite.ToRow (Only a) where+    toRow (Only v) = SQLite.toRow $ SQLite.Only v++instance SQLite.FromField a => SQLite.FromRow (Only a) where+    fromRow = Only <$> SQLite.field++instance (SQLite.ToRow a, SQLite.ToRow b) => SQLite.ToRow (a :. b) where+    toRow (a :. b) = SQLite.toRow $ a SQLite.:. b++instance (SQLite.FromRow a, SQLite.FromRow b) => SQLite.FromRow (a :. b) where+    fromRow = (\(a SQLite.:. b) -> a :. b) <$> SQLite.fromRow++
+ 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-sqlite.cabal view
@@ -0,0 +1,26 @@+name:                sql-simple-sqlite+version:             0.1.0.0+synopsis:            sqlite 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.SQLite+  build-depends:       base                 >=4.6 && <4.8+                     , sql-simple           >=0.1 && <0.2+                     , sqlite-simple        >=0.4 && <0.5++  if impl(ghc < 7.8)+    build-depends:     tagged               >=0.7 && <0.8++  ghc-options:         -Wall -O2+  default-language:    Haskell2010