git.iko.soy/typeable/postgresql-simple
on master help sign in
Fix up some warnings
commit64f5abafbedb81274a36ed8fa79f89a34e509418 authorLeon P Smith <leon@melding-monads.com> dateThu 8 Mar 2012, 15:11 (15 years ago) parente93b346
3 files changed+6−27
src/Database/PostgreSQL/Simple.hs+3−21 src/Database/PostgreSQL/Simple/FromField.hs+1−1 src/Database/PostgreSQL/Simple/FromRow.hs+2−5
src/Database/PostgreSQL/Simple.hs+3−21
@@ -110,7 +110,7 @@ import Blaze.ByteString.Builder.Char8 (fromChar)
110110import Control.Applicative ((<$>), pure)
111111import Control.Concurrent.MVar
112112import Control.Exception
113− ( Exception, bracket, onException, throw, throwIO, finally )
113+ ( Exception, onException, throw, throwIO, finally )
114114import Control.Monad (foldM)
115115import Data.ByteString (ByteString)
116116import Data.Char(ord)
@@ -121,6 +121,7 @@ import Data.Monoid (mappend, mconcat)
121121import Data.Typeable (Typeable)
122122import Database.PostgreSQL.Simple.BuiltinTypes
123123 ( oid2builtin, builtin2typname )
124+import Database.PostgreSQL.Simple.Compat ( mask )
124125import Database.PostgreSQL.Simple.FromField (ResultError(..))
125126import Database.PostgreSQL.Simple.FromRow (FromRow(..))
126127import Database.PostgreSQL.Simple.Ok
@@ -133,7 +134,6 @@ import qualified Database.PostgreSQL.LibPQ as PQ
133134import Text.Regex.PCRE.Light (compile, caseless, match)
134135import qualified Data.ByteString.Char8 as B
135136import qualified Data.Vector as V
136−import Control.Exception
137137import Control.Monad.Trans.Reader
138138import Control.Monad.Trans.State.Strict
139139
@@ -471,7 +471,7 @@ finishQuery conn q result = do
471471 throwIO $ QueryError "query resulted in a command response" q
472472 PQ.TuplesOk -> do
473473 ncols <- PQ.nfields result
474− let unCol (PQ.Col x) = fromIntegral x
474+ let unCol (PQ.Col x) = fromIntegral x :: Int
475475 typenames <- V.generateM (unCol ncols)
476476 (\(PQ.Col . fromIntegral -> col) -> do
477477 getTypename conn =<< PQ.ftype result col)
@@ -500,24 +500,6 @@ ellipsis bs
500500 | B.length bs > 15 = B.take 10 bs `B.append` "[...]"
501501 | otherwise = bs
502502
503−-- | Throw a 'ConversionFailed' exception, indicating a mismatch
504−-- between the number of columns in the 'Field' and row, and the
505−-- number in the collection to be converted to.
506−convertError :: [Field]
507− -- ^ Descriptors of fields to be converted.
508− -> [Maybe ByteString]
509− -- ^ Contents of the row to be converted.
510− -> Int
511− -- ^ Number of columns expected for conversion. For
512− -- instance, if converting to a 3-tuple, the number to
513− -- provide here would be 3.
514− -> Either SomeException a
515−convertError fs vs n = Left . SomeException $ ConversionFailed
516− (show (length fs) ++ " values: " ++ show (zip (map typename fs)
517− (map (fmap ellipsis) vs)))
518− (show n ++ " slots in target type")
519− "mismatch between number of columns to convert and number in target type"
520−
521503
522504-- | Of the four isolation levels defined by the SQL standard,
523505-- these are the three levels distinguished by PostgreSQL as of version 9.0.
src/Database/PostgreSQL/Simple/FromField.hs+1−1
@@ -32,7 +32,7 @@ module Database.PostgreSQL.Simple.FromField
3232#include "MachDeps.h"
3333
3434import Control.Applicative (Applicative, (<|>), (<$>), (<*>), (<*), pure)
35−import Control.Exception (SomeException(..), Exception, throw)
35+import Control.Exception (SomeException(..), Exception)
3636import Data.Attoparsec.Char8 hiding (Result)
3737import Data.Bits ((.&.), (.|.), shiftL)
3838import Data.ByteString (ByteString)
src/Database/PostgreSQL/Simple/FromRow.hs+2−5
@@ -24,11 +24,10 @@ module Database.PostgreSQL.Simple.FromRow
2424 ) where
2525
2626import Control.Applicative (Applicative(..), (<$>))
27−import Control.Exception (SomeException(..), throw)
27+import Control.Exception (SomeException(..))
2828import Control.Monad (replicateM)
2929import Data.ByteString (ByteString)
3030import qualified Data.ByteString.Char8 as B
31−import Database.PostgreSQL.Simple.Internal
3231import Database.PostgreSQL.Simple.Types (Only(..))
3332import Database.PostgreSQL.Simple.Ok
3433import qualified Database.PostgreSQL.LibPQ as PQ
@@ -41,14 +40,12 @@ import Control.Monad.Trans.Class
4140
4241import Data.Vector ((!))
4342
44−import System.IO.Unsafe ( unsafePerformIO )
45−
4643class FromRow a where
4744 fromRow :: RowParser a
4845
4946field :: FromField a => RowParser a
5047field = RP $ do
51− let unCol (PQ.Col x) = fromIntegral x
48+ let unCol (PQ.Col x) = fromIntegral x :: Int
5249 Row{..} <- ask
5350 column <- lift get
5451 lift (put (column + 1))