packages feed

convertible-text 0.2.0.5 → 0.3.0

raw patch · 3 files changed

+24/−12 lines, 3 filesdep −safe-failuredep ~attemptPVP ok

version bump matches the API change (PVP)

Dependencies removed: safe-failure

Dependency ranges changed: attempt

API changes (from Hackage documentation)

+ Data.Convertible.Instances.String: instance ConvertAttempt [Char] Integer
+ Data.Convertible.Instances.String: instance ConvertSuccess Integer [Char]
- Data.Convertible.Base: convertAttemptWrap :: (ConvertAttempt a b, MonadFailure ConversionException m) => a -> m b
+ Data.Convertible.Base: convertAttemptWrap :: (ConvertAttempt a b, Failure ConversionException m) => a -> m b

Files

Data/Convertible/Base.hs view
@@ -95,7 +95,7 @@  'ConversionException' -} convertAttemptWrap :: (ConvertAttempt a b,-                       MonadFailure ConversionException m+                       Failure ConversionException m                       )                    => a                    -> m b
Data/Convertible/Instances/String.hs view
@@ -31,10 +31,9 @@ import Data.Convertible.Base import Data.Typeable (Typeable) import Control.Exception (Exception)-import qualified Safe.Failure as SF import Data.Convertible.Instances.Text () import Data.Attempt-import Control.Monad ((<=<))+import Control.Monad ((<=<), unless)  import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BL@@ -95,10 +94,10 @@     convertSuccess = show instance ConvertAttempt [Char] Day where     convertAttempt s = wrapFailure (const $ InvalidDayException s) $ do-        SF.assert (length s == 10) () $ InvalidDayException s-        y <- SF.read $ take 4 s-        m <- SF.read $ take 2 $ drop 5 s-        d <- SF.read $ take 2 $ drop 8 s+        unless (length s == 10) $ failure $ InvalidDayException s+        y <- ca $ take 4 s+        m <- ca $ take 2 $ drop 5 s+        d <- ca $ take 2 $ drop 8 s         return $ fromGregorian y m d  -- Bool@@ -142,15 +141,29 @@ instance ConvertSuccess Int [Char] where     convertSuccess = show instance ConvertAttempt [Char] Int where-    convertAttempt = SF.read+    convertAttempt = readMsg "Invalid Int" +-- Integer+instance ConvertSuccess Integer [Char] where+    convertSuccess = show+instance ConvertAttempt [Char] Integer where+    convertAttempt = readMsg "Invalid Int"+ -- Rational instance ConvertSuccess Rational [Char] where     convertSuccess r         | denominator r == 1 = show $ numerator r         | otherwise = show $ (fromRational r :: Double) instance ConvertAttempt [Char] Rational where-    convertAttempt = fmap realToFrac . (SF.read :: String -> Attempt Double)+    convertAttempt = fmap realToFrac . readDouble++readDouble :: String -> Attempt Double+readDouble = readMsg "Invalid double"++readMsg :: Read a => String -> String -> Attempt a+readMsg msg s = case reads s of+                    (x, _):_ -> Success x+                    _ -> failureString $ msg ++ ": " ++ s  #if TEST propRationalId :: Rational -> Bool
convertible-text.cabal view
@@ -1,5 +1,5 @@ Name: convertible-text-Version: 0.2.0.5+Version: 0.3.0 License: LGPL Maintainer: Michael Snoyman <michael@snoyman.com> Author: John Goerzen, Michael Snoyman@@ -43,8 +43,7 @@                  containers >= 0.2.0.1 && < 0.4,                  text >= 0.5 && < 0.8,                  bytestring >= 0.9.1.4 && < 0.10,-                 safe-failure >= 0.4 && < 0.5,-                 attempt >= 0.2.1 && < 0.3,+                 attempt >= 0.3.0 && < 0.4,                  template-haskell   if flag(time_gte_113)     Build-Depends: time>=1.1.3 && <= 1.1.4