@@ -56,6 +56,7 @@ import qualified Data.ByteString.Char8 as B8
56import qualified Data.ByteString.Lazy as LB
56import qualified Data.ByteString.Lazy as LB
57import qualified Data.Text as ST
57import qualified Data.Text as ST
58import qualified Data.Text.Encoding as ST
58import qualified Data.Text.Encoding as ST
59+import qualified Data.Text.Encoding.Error (UnicodeException)
59import qualified Data.Text.Lazy as LT
60import qualified Data.Text.Lazy as LT
61-- | Exception thrown if conversion from a SQL value to a Haskell
62-- | Exception thrown if conversion from a SQL value to a Haskell
@@ -90,7 +91,7 @@ class Result a where
91 -- Returns an exception if the conversion fails. In the case of
92 -- Returns an exception if the conversion fails. In the case of
92 -- library instances, this will usually be a 'ResultError', but may
93 -- library instances, this will usually be a 'ResultError', but may
93− -- be a 'UnicodeError'.
94+ -- be a 'UnicodeException'.
95instance (Result a) => Result (Maybe a) where
96instance (Result a) => Result (Maybe a) where
96 convert _ Nothing = pure Nothing
97 convert _ Nothing = pure Nothing
@@ -159,11 +160,11 @@ instance Result LB.ByteString where
161instance Result ST.Text where
162instance Result ST.Text where
163+ convert f = doConvert f okText $ (either left Right . ST.decodeUtf8')
162− convert f {- | isText f -} = doConvert f okText $ (Right . ST.decodeUtf8)
164+{- | isText f = doConvert f okText $ (Right . ST.decodeUtf8)
163−{- | otherwise = incompatible f (typeOf ST.empty)
165+ | otherwise = incompatible f (typeOf ST.empty)
164 "attempt to mix binary and text" -}
166 "attempt to mix binary and text" -}
165− -- FIXME: return a "Fail someUnicodeError" instead of throwing it
166− -- check character encoding
167+ -- FIXME: check character encoding
168instance Result LT.Text where
169instance Result LT.Text where
169 convert f dat = LT.fromStrict <$> convert f dat
170 convert f dat = LT.fromStrict <$> convert f dat