packages feed

convertible 1.0.9 → 1.0.9.1

raw patch · 6 files changed

+49/−44 lines, 6 filesdep ~QuickCheckdep ~testpackdep ~timePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: QuickCheck, testpack, time

API changes (from Hackage documentation)

- Data.Convertible.Instances.Map: instance (Ord k) => Convertible [(k, a)] (Map k a)
+ Data.Convertible.Instances.Map: instance Ord k => Convertible [(k, a)] (Map k a)
- Data.Convertible.Base: convert :: (Convertible a b) => a -> b
+ Data.Convertible.Base: convert :: Convertible a b => a -> b
- Data.Convertible.Base: safeConvert :: (Convertible a b) => a -> ConvertResult b
+ Data.Convertible.Base: safeConvert :: Convertible a b => a -> ConvertResult b

Files

Data/Convertible/Instances/Num.hs view
@@ -18,7 +18,7 @@ These instances perform conversion between numeric types such as Double, Int, Integer, Rational, and the like.  Here are some notes about the conversion process: -Conversions from floating-point types such as Double to integral types are dune via the+Conversions from floating-point types such as Double to integral types are done via the 'truncate' function.  This is a somewhat arbitrary decision; if you need different behavior, you will have to write your own instance or manually perform the conversion. 
convertible.cabal view
@@ -1,5 +1,5 @@ Name: convertible-Version: 1.0.9+Version: 1.0.9.1 License: LGPL Maintainer: John Goerzen <jgoerzen@complete.org> Author: John Goerzen@@ -50,7 +50,7 @@  library   if flag(splitBase)-    Build-Depends: base>=3 && <5, old-time, time>=1.1.2.4 && <=1.1.4,+    Build-Depends: base>=3 && <5, old-time, time>=1.1.2.4 && <=1.2.0.3,      bytestring, containers, old-locale     if flag(time_gte_113)       Build-Depends: time>=1.1.3@@ -82,7 +82,12 @@ Executable runtests    if flag(buildtests)       Buildable: True-      Build-Depends: HUnit, QuickCheck, testpack+      Build-Depends: HUnit, QuickCheck >= 2.0, testpack >= 2.0+      if flag(time_gte_113)+        Build-Depends: time>=1.1.3+        CPP-OPTIONS: -DTIME_GT_113+      else+        Build-Depends: time<1.1.3    else       Buildable: False    Main-Is: runtests.hs@@ -90,4 +95,4 @@    GHC-Options: -O2    Extensions: ExistentialQuantification, MultiParamTypeClasses,                UndecidableInstances, FlexibleInstances,-               FlexibleContexts, TypeSynonymInstances+               FlexibleContexts, TypeSynonymInstances, CPP
testsrc/TestInfrastructure.hs view
@@ -13,5 +13,3 @@ q :: QC.Testable a => String -> a -> HU.Test q = qc2hu 250 -qverbose :: QC.Testable a => String -> a -> HU.Test-qverbose = qc2huVerbose 250
testsrc/TestMap.hs view
@@ -12,12 +12,13 @@ import Test.QuickCheck import Test.QuickCheck.Tools import Test.QuickCheck.Instances+import qualified Test.QuickCheck.Property as P import qualified Data.Map as Map -propListMap :: [(Int, Int)] -> Result+propListMap :: [(Int, Int)] -> P.Result propListMap x = safeConvert x @?= Right (Map.fromList x) -propMapList :: Map.Map Int Int -> Result+propMapList :: Map.Map Int Int -> P.Result propMapList x = safeConvert x @?= Right (Map.toList x)  allt = [q "[(Int, Int)] -> Map" propListMap,
testsrc/TestNum.hs view
@@ -11,9 +11,10 @@ import Data.Convertible import Test.QuickCheck import Test.QuickCheck.Tools+import qualified Test.QuickCheck.Property as P import Data.Word -prop_int_to_integer :: Int -> Result+prop_int_to_integer :: Int -> P.Result prop_int_to_integer x =     safeConvert x @?= Right ((fromIntegral x)::Integer) @@ -23,7 +24,7 @@     (x >= fromIntegral (minBound :: Int)) ==>                                            safeConvert x @?= Right ((fromIntegral x)::Int) -prop_integer_to_word8 :: Integer -> Result+prop_integer_to_word8 :: Integer -> P.Result prop_integer_to_word8 x =     safeConvert x @?= if x >= fromIntegral (minBound :: Word8) &&                          x <= fromIntegral (maxBound :: Word8)@@ -42,7 +43,7 @@     x > fromIntegral (maxBound :: Word8) ==>       ((safeConvert x)::ConvertResult Word8) @?= (Left $ ConvertError (show x) "Integer" "Word8" "Input value outside of bounds: (0,255)") -prop_double_to_word8 :: Double -> Result+prop_double_to_word8 :: Double -> P.Result prop_double_to_word8 x =     safeConvert x @?= if truncate x >= toInteger (minBound :: Word8) &&                          truncate x <= toInteger (maxBound :: Word8)@@ -61,29 +62,28 @@     truncate x > toInteger (maxBound :: Word8) ==>       ((safeConvert x)::ConvertResult Word8) @?= (Left $ ConvertError (show x) "Double" "Word8" "Input value outside of bounds: (0,255)") -propIntDouble :: Int -> Result+propIntDouble :: Int -> P.Result propIntDouble x =     safeConvert x @?= Right ((fromIntegral x)::Double) -propIntChar :: Int -> Result+propIntChar :: Int -> P.Result propIntChar x =     safeConvert x @?= if x >= fromEnum (minBound :: Char) &&                          x <= fromEnum (maxBound :: Char)                       then Right ((toEnum x)::Char)                       else Left $ ConvertError (show x) "Int" "Char" "Input value outside of bounds: ('\\NUL','\\1114111')" -propCharInt :: Int -> Property-propCharInt x =-    x >= fromEnum (minBound :: Char) && x <= fromEnum (maxBound :: Char) ==>+propCharInt :: Char -> P.Result+propCharInt c =     safeConvert c @?= Right ((fromEnum c)::Int)-    where c = (toEnum x)::Char+    where x = fromEnum c -propIntIntegerInt :: Int -> Result+propIntIntegerInt :: Int -> P.Result propIntIntegerInt x =     Right x @=? do r1 <- ((safeConvert x)::ConvertResult Integer)                    ((safeConvert r1)::ConvertResult Int)     -propDoubleRationalDouble :: Double -> Result+propDoubleRationalDouble :: Double -> P.Result propDoubleRationalDouble x =     Right x @=? do r1 <- ((safeConvert x)::ConvertResult Rational)                    ((safeConvert r1)::ConvertResult Double)
testsrc/TestTime.hs view
@@ -12,6 +12,7 @@ import Test.QuickCheck import Test.QuickCheck.Tools import Test.QuickCheck.Instances+import qualified Test.QuickCheck.Property as P import qualified System.Time as ST import Data.Time import Data.Time.Clock.POSIX@@ -22,7 +23,7 @@     arbitrary = do r1 <- arbitrary                    r2 <- sized $ \n -> choose (0, 1000000000000 - 1)                    return (ST.TOD r1 r2)-    coarbitrary (ST.TOD a b) = coarbitrary a . coarbitrary b+    -- coarbitrary (ST.TOD a b) = coarbitrary a . coarbitrary b  instance Arbitrary ST.CalendarTime where     arbitrary = do r <- arbitrary@@ -43,34 +44,34 @@ instance Eq ZonedTime where     a == b = zonedTimeToUTC a == zonedTimeToUTC b -propCltCalt :: ST.ClockTime -> Result+propCltCalt :: ST.ClockTime -> P.Result propCltCalt x =     safeConvert x @?= Right (ST.toUTCTime x) -propCltCaltClt :: ST.ClockTime -> Result+propCltCaltClt :: ST.ClockTime -> P.Result propCltCaltClt x =     Right x @=? do r1 <- ((safeConvert x)::ConvertResult ST.CalendarTime)                    safeConvert r1 -propCltPT :: ST.ClockTime -> Result+propCltPT :: ST.ClockTime -> P.Result propCltPT x@(ST.TOD y z) =     safeConvert x @?= Right (r::POSIXTime)     where r = fromRational $ fromInteger y + fromRational (z % 1000000000000) -propPTClt :: POSIXTime -> Result+propPTClt :: POSIXTime -> P.Result propPTClt x =     safeConvert x @?= Right (r::ST.ClockTime)     where r = ST.TOD rsecs rpico           rsecs = floor x           rpico = truncate $ abs $ 1000000000000 * (x - (fromIntegral rsecs)) -propCaltPT :: ST.CalendarTime -> Result+propCaltPT :: ST.CalendarTime -> P.Result propCaltPT x =     safeConvert x @?= expected         where expected = do r <- safeConvert x                             (safeConvert (r :: ST.ClockTime))::ConvertResult POSIXTime -propCltPTClt :: ST.ClockTime -> Result+propCltPTClt :: ST.ClockTime -> P.Result propCltPTClt x =     Right (toTOD x) @=? case do r1 <- (safeConvert x)::ConvertResult POSIXTime                                 safeConvert r1@@ -82,74 +83,74 @@                    safeConvert r1 -} -propPTZTPT :: POSIXTime -> Result+propPTZTPT :: POSIXTime -> P.Result propPTZTPT x =     Right x @=? do r1 <- safeConvert x                    safeConvert (r1 :: ZonedTime) -propPTCltPT :: POSIXTime -> Result+propPTCltPT :: POSIXTime -> P.Result propPTCltPT x =     Right x @=? do r1 <- (safeConvert x)::ConvertResult ST.ClockTime                    safeConvert r1 -propPTCalPT :: POSIXTime -> Result+propPTCalPT :: POSIXTime -> P.Result propPTCalPT x =     Right x @=? do r1 <- safeConvert x                    safeConvert (r1::ST.CalendarTime) -propUTCCaltUTC :: UTCTime -> Result+propUTCCaltUTC :: UTCTime -> P.Result propUTCCaltUTC x =     Right x @=? do r1 <- safeConvert x                    safeConvert (r1::ST.CalendarTime) -propPTUTC :: POSIXTime -> Result+propPTUTC :: POSIXTime -> P.Result propPTUTC x =     safeConvert x @?= Right (posixSecondsToUTCTime x)-propUTCPT :: UTCTime -> Result+propUTCPT :: UTCTime -> P.Result propUTCPT x =     safeConvert x @?= Right (utcTimeToPOSIXSeconds x) -propCltUTC :: ST.ClockTime -> Result+propCltUTC :: ST.ClockTime -> P.Result propCltUTC x =     safeConvert x @?= Right (posixSecondsToUTCTime . convert $ x) -propZTCTeqZTCaltCt :: ZonedTime -> Result+propZTCTeqZTCaltCt :: ZonedTime -> P.Result propZTCTeqZTCaltCt x =     route1 @=? route2     where route1 = (safeConvert x)::ConvertResult ST.ClockTime           route2 = do calt <- safeConvert x                       safeConvert (calt :: ST.CalendarTime) -propCaltZTCalt :: ST.ClockTime -> Result+propCaltZTCalt :: ST.ClockTime -> P.Result propCaltZTCalt x =     Right x @=? do zt <- ((safeConvert calt)::ConvertResult ZonedTime)                    calt' <- ((safeConvert zt)::ConvertResult ST.CalendarTime)                    return (ST.toClockTime calt')     where calt = ST.toUTCTime x -propCaltZTCalt2 :: ST.CalendarTime -> Result+propCaltZTCalt2 :: ST.CalendarTime -> P.Result propCaltZTCalt2 x =     Right x @=? do zt <- safeConvert x                    safeConvert (zt :: ZonedTime) -propZTCaltCtZT :: ZonedTime -> Result+propZTCaltCtZT :: ZonedTime -> P.Result propZTCaltCtZT x =     Right x @=? do calt <- safeConvert x                    ct <- safeConvert (calt :: ST.CalendarTime)                    safeConvert (ct :: ST.ClockTime) -propZTCtCaltZT :: ZonedTime -> Result+propZTCtCaltZT :: ZonedTime -> P.Result propZTCtCaltZT x =     Right x @=? do ct <- safeConvert x                    calt <- safeConvert (ct :: ST.ClockTime)                    safeConvert (calt :: ST.CalendarTime) -propZTCaltZT :: ZonedTime -> Result+propZTCaltZT :: ZonedTime -> P.Result propZTCaltZT x =     Right x @=? do calt <- safeConvert x                    safeConvert (calt :: ST.CalendarTime) -propZTCtCaltCtZT :: ZonedTime -> Result+propZTCtCaltCtZT :: ZonedTime -> P.Result propZTCtCaltCtZT x =     Right x @=? do ct <- safeConvert x                    calt <- safeConvert (ct :: ST.ClockTime)@@ -160,17 +161,17 @@ propUTCZT x =           x == zonedTimeToUTC (convert x) -propUTCZTUTC :: UTCTime -> Result+propUTCZTUTC :: UTCTime -> P.Result propUTCZTUTC x =     Right x @=? do r1 <- ((safeConvert x)::ConvertResult ZonedTime)                    safeConvert r1 -propNdtTdNdt :: NominalDiffTime -> Result+propNdtTdNdt :: NominalDiffTime -> P.Result propNdtTdNdt x =     Right x @=? do r1 <- ((safeConvert x)::ConvertResult ST.TimeDiff)                    safeConvert r1 -propPTCPT :: POSIXTime -> Result+propPTCPT :: POSIXTime -> P.Result propPTCPT x =     Right testval @=? do r1 <- safeConvert testval                          safeConvert (r1 :: CTime)