Permalink
Browse files

Tidy imports.

  • Loading branch information...
bos committed Apr 29, 2011
1 parent 5f11108 commit ef8c42bca0cbf300378368b41d16ac012068cbed
View
@@ -6,20 +6,20 @@ module Database.MySQL.Simple
, formatQuery
) where
-import Control.Applicative
-import Data.Int (Int64)
-import Control.DeepSeq
-import Control.Monad.Fix
-import Blaze.ByteString.Builder
-import qualified Data.ByteString.Char8 as B
+import Blaze.ByteString.Builder (fromByteString, toByteString)
+import Control.Applicative ((<$>), pure)
+import Control.DeepSeq (NFData(..))
+import Control.Monad.Fix (fix)
import Data.ByteString (ByteString)
-import Data.Monoid
+import Data.Int (Int64)
+import Data.Monoid (mappend, mempty)
import Database.MySQL.Base (Connection)
+import Database.MySQL.Simple.Param (Action(..), inQuotes)
+import Database.MySQL.Simple.QueryParams (QueryParams(..))
+import Database.MySQL.Simple.QueryResults (QueryResults(..))
+import Database.MySQL.Simple.Types (Query(..))
+import qualified Data.ByteString.Char8 as B
import qualified Database.MySQL.Base as Base
-import Database.MySQL.Simple.Param
-import Database.MySQL.Simple.QueryParams
-import Database.MySQL.Simple.QueryResults
-import Database.MySQL.Simple.Types
formatQuery :: QueryParams q => Connection -> Query -> q -> IO ByteString
formatQuery conn (Query template) qs
@@ -3,12 +3,12 @@
module Database.MySQL.Simple.Orphans () where
+import Control.DeepSeq (NFData(..))
import Data.Time.Calendar (Day(..))
import Data.Time.Clock (UTCTime(..))
import Data.Time.LocalTime (TimeOfDay(..))
import qualified Data.ByteString.Internal as SB
import qualified Data.ByteString.Lazy.Internal as LB
-import Control.DeepSeq (NFData(..))
instance NFData SB.ByteString where
rnf (SB.PS _ _ _) = ()
@@ -10,14 +10,14 @@ module Database.MySQL.Simple.Param
import Blaze.ByteString.Builder (Builder, fromByteString, toByteString)
import Blaze.Text (integral, double, float)
import Data.ByteString (ByteString)
-import Data.Monoid (mappend)
-import Database.MySQL.Simple.Types (Null)
import Data.Int (Int8, Int16, Int32, Int64)
+import Data.Monoid (mappend)
import Data.Time.Calendar (Day, showGregorian)
import Data.Time.Clock (UTCTime)
-import Data.Time.LocalTime (TimeOfDay)
import Data.Time.Format (formatTime)
+import Data.Time.LocalTime (TimeOfDay)
import Data.Word (Word, Word8, Word16, Word32, Word64)
+import Database.MySQL.Simple.Types (Null)
import System.Locale (defaultTimeLocale)
import qualified Blaze.ByteString.Builder.Char.Utf8 as Utf8
import qualified Data.ByteString as SB
@@ -3,8 +3,8 @@ module Database.MySQL.Simple.QueryParams
QueryParams(..)
) where
-import Database.MySQL.Simple.Param
-import Database.MySQL.Simple.Types
+import Database.MySQL.Simple.Param (Action(..), Param(..))
+import Database.MySQL.Simple.Types (Only(..))
class QueryParams a where
renderParams :: a -> [Action]
@@ -4,10 +4,11 @@ module Database.MySQL.Simple.QueryResults
) where
import Control.DeepSeq (NFData(..))
+import Control.Exception (throw)
import Data.ByteString (ByteString)
-import Database.MySQL.Base.Types
-import Database.MySQL.Simple.Result
-import Database.MySQL.Simple.Types
+import Database.MySQL.Base.Types (Field)
+import Database.MySQL.Simple.Result (ResultError(..), Result(..))
+import Database.MySQL.Simple.Types (Only(..))
class (NFData a) => QueryResults a where
convertResults :: [Field] -> [Maybe ByteString] -> a
@@ -94,4 +95,7 @@ instance (NFData a, NFData b, NFData c, NFData d, NFData e, NFData f,
convertResults fs vs = convError fs vs
convError :: [Field] -> [Maybe ByteString] -> a
-convError = error "convError"
+convError fs vs = throw $ ConversionFailed
+ (show (length fs) ++ " columns left in result")
+ (show (length vs) ++ " values left in row")
+ "mismatch between number of columns to convert"
@@ -8,30 +8,30 @@ module Database.MySQL.Simple.Result
#include "MachDeps.h"
-import Data.Typeable
-import Database.MySQL.Simple.Orphans ()
+import Control.Applicative ((<$>), (<*>), (<*), pure)
import Control.DeepSeq (NFData)
-import Control.Applicative
-import Control.Exception
-import Data.ByteString (ByteString)
-import Database.MySQL.Base.Types
+import Control.Exception (Exception, throw)
import Data.Attoparsec.Char8 hiding (Result)
-import Data.Bits
+import Data.Bits ((.&.), (.|.), shiftL)
+import Data.ByteString (ByteString)
+import Data.Int (Int8, Int16, Int32, Int64)
+import Data.List (foldl')
+import Data.Ratio (Ratio)
import Data.Time.Calendar (Day, fromGregorian)
import Data.Time.Clock (UTCTime)
+import Data.Time.Format (parseTime)
import Data.Time.LocalTime (TimeOfDay, makeTimeOfDayValid)
-import System.Locale (defaultTimeLocale)
-import Data.Int (Int8, Int16, Int32, Int64)
+import Data.Typeable (TypeRep, Typeable, typeOf)
import Data.Word (Word, Word8, Word16, Word32, Word64)
-import Data.Ratio (Ratio)
-import Data.List
+import Database.MySQL.Base.Types (Field(..), Type(..))
+import Database.MySQL.Simple.Orphans ()
+import System.Locale (defaultTimeLocale)
import qualified Data.ByteString as SB
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy as LB
import qualified Data.Text as ST
import qualified Data.Text.Encoding as ST
import qualified Data.Text.Lazy as LT
-import Data.Time.Format (parseTime)
data ResultError = Incompatible { errSourceType :: String
, errDestType :: String

0 comments on commit ef8c42b

Please sign in to comment.