summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWrenThornton <>2014-03-08 21:30:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-03-08 21:30:00 (GMT)
commita483b67b0cddcb61d1e921c5befb4d9a0b63eaa0 (patch)
tree3c614664ce6d300aa09a66be04bb9db992df6c2b
parent52d05e68b283724887d7f05fb4e3c453680254db (diff)
version 0.1.10.1.1
-rw-r--r--LICENSE2
-rw-r--r--README2
-rw-r--r--VERSION2
-rw-r--r--data-fin.cabal14
-rw-r--r--src/Data/Number/Fin/Int16.hs45
-rw-r--r--src/Data/Number/Fin/Int32.hs40
-rw-r--r--src/Data/Number/Fin/Int64.hs40
-rw-r--r--src/Data/Number/Fin/Int8.hs47
-rw-r--r--src/Data/Number/Fin/Integer.hs41
9 files changed, 213 insertions, 20 deletions
diff --git a/LICENSE b/LICENSE
index f9b11f9..2b0f6fb 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2012, 2013 wren ng thornton.
+Copyright (c) 2012, 2013, 2014 wren ng thornton.
ALL RIGHTS RESERVED.
Redistribution and use in source and binary forms, with or without
diff --git a/README b/README
index 6684eb7..985c88e 100644
--- a/README
+++ b/README
@@ -30,7 +30,7 @@ Portability
While I usually try to keep things as portable as possible, this
package relies on many GHC language extensions. Thus, no claim of
-portability ot non-GHC copilers is made. All the required language
+portability ot non-GHC compilers is made. All the required language
extensions are:
CPP
diff --git a/VERSION b/VERSION
index 08f5388..9136a52 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,4 @@
+0.1.1 (2014.03.07):
+ - Updated to work with SmallCheck >= 1.0 && < 1.2
0.1.0 (2013.07.20):
- Initial release \ No newline at end of file
diff --git a/data-fin.cabal b/data-fin.cabal
index 6a265f9..ab93f01 100644
--- a/data-fin.cabal
+++ b/data-fin.cabal
@@ -1,5 +1,5 @@
----------------------------------------------------------------
--- wren ng thornton <wren@community.haskell.org> ~ 2013.07.20
+-- wren ng thornton <wren@community.haskell.org> ~ 2014.03.07
----------------------------------------------------------------
-- By and large Cabal >=1.2 is fine; but >= 1.6 gives tested-with:
@@ -8,12 +8,12 @@ Cabal-Version: >= 1.6
Build-Type: Simple
Name: data-fin
-Version: 0.1.0
+Version: 0.1.1
Stability: experimental
Homepage: http://code.haskell.org/~wren/
Author: wren ng thornton
Maintainer: wren@community.haskell.org
-Copyright: Copyright (c) 2012--2013 wren ng thornton
+Copyright: Copyright (c) 2012--2014 wren ng thornton
License: BSD3
License-File: LICENSE
@@ -25,7 +25,7 @@ Description:
Tested-With:
- GHC ==6.12.1
+ GHC ==6.12.1, GHC ==7.6.1, GHC ==7.8.2
Extra-source-files:
AUTHORS, README, VERSION
Source-Repository head
@@ -63,11 +63,11 @@ Library
-- Data.Reflection.OfType
Other-Modules: Data.Number.Fin.TyOrdering
- Build-Depends: tagged >= 0.2.3 && < 0.7
- , reflection >= 1.1.6 && < 1.4
+ Build-Depends: tagged >= 0.2.3 && < 0.8
+ , reflection >= 1.1.6 && < 1.5
, prelude-safeenum < 0.2
-- N.B., major smallcheck API break between 0.5 and 0.6
- , smallcheck >= 0.4 && < 0.7
+ , smallcheck >= 0.4 && < 1.2
, lazysmallcheck >= 0.5 && < 0.7
, QuickCheck >= 2.4.1.1 && < 2.7
diff --git a/src/Data/Number/Fin/Int16.hs b/src/Data/Number/Fin/Int16.hs
index fe2e710..b26428c 100644
--- a/src/Data/Number/Fin/Int16.hs
+++ b/src/Data/Number/Fin/Int16.hs
@@ -3,6 +3,7 @@
, DeriveDataTypeable
, MultiParamTypeClasses
, FlexibleContexts
+ , FlexibleInstances
, CPP
, Rank2Types
, UndecidableInstances
@@ -13,10 +14,10 @@
{-# LANGUAGE Trustworthy #-}
#endif
----------------------------------------------------------------
--- 2013.05.29
+-- 2014.03.07
-- |
-- Module : Data.Number.Fin.Int16
--- Copyright : 2012--2013 wren ng thornton
+-- Copyright : 2012--2014 wren ng thornton
-- License : BSD3
-- Maintainer : wren@community.haskell.org
-- Stability : experimental
@@ -78,6 +79,9 @@ import Data.Reflection (Reifies(reflect), reify)
import Control.Monad (liftM)
import qualified Test.QuickCheck as QC
+#if (MIN_VERSION_smallcheck(1,0,0))
+import Test.SmallCheck.Series ((>>-))
+#endif
#if (MIN_VERSION_smallcheck(0,6,0))
import qualified Test.SmallCheck.Series as SC
#else
@@ -465,7 +469,34 @@ instance (NatLE n MaxBoundInt16, Nat n) => QC.CoArbitrary (Fin n) where
coarbitrary (Fin n) = QC.variant n
+#if (MIN_VERSION_smallcheck(1,0,0))
+instance (NatLE n MaxBoundInt16, Nat n, Monad m) => SC.Serial m (Fin n) where
+ -- SC.series :: Series m (Fin n)
+ series = SC.generate $ \d ->
+ if d < 0
+ then [] -- paranoia.
+ else
+ case toFin (fromIntegral d) of
+ Nothing -> enumFromTo minBound maxBound
+ Just n -> enumFromTo minBound n
+
+instance (NatLE n MaxBoundInt16, Nat n, Monad m) => SC.CoSerial m (Fin n) where
+ -- SC.coseries :: Series m b -> Series m (Fin n -> b)
+ coseries rs =
+ SC.alts0 rs >>- \z ->
+ SC.alts1 rs >>- \f ->
+ return $ \(Fin i) ->
+ if i > 0
+ then
+ let j = Fin (i-1) :: Fin n
+ in f j `checking` j -- more paranoia; in case n==0 or i>n
+ else z
+
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
instance (NatLE n MaxBoundInt16, Nat n) => SC.Serial (Fin n) where
+ -- SC.series :: Series (Fin n)
+ -- SC.series :: Int -> [Fin n]
series d
| d < 0 = [] -- paranoia.
| otherwise =
@@ -473,6 +504,8 @@ instance (NatLE n MaxBoundInt16, Nat n) => SC.Serial (Fin n) where
Nothing -> enumFromTo minBound maxBound
Just n -> enumFromTo minBound n
+ -- SC.coseries :: Series b -> Series (Fin n -> b)
+ -- SC.coseries :: (Int -> [b]) -> (Int -> [Fin n -> b])
coseries rs d =
[ \(Fin i) ->
if i > 0
@@ -482,9 +515,17 @@ instance (NatLE n MaxBoundInt16, Nat n) => SC.Serial (Fin n) where
| z <- SC.alts0 rs d
, f <- SC.alts1 rs d
]
+#endif
instance (NatLE n MaxBoundInt16, Nat n) => LSC.Serial (Fin n) where
+ -- LSC.series :: Series (Fin n)
+ -- LSC.series :: Int -> Cons (Fin n)
+#if (MIN_VERSION_smallcheck(1,0,0))
+ series = LSC.drawnFrom . (`SC.list` SC.series)
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
series = LSC.drawnFrom . SC.series
+#endif
----------------------------------------------------------------
diff --git a/src/Data/Number/Fin/Int32.hs b/src/Data/Number/Fin/Int32.hs
index a6628ef..faa8722 100644
--- a/src/Data/Number/Fin/Int32.hs
+++ b/src/Data/Number/Fin/Int32.hs
@@ -3,6 +3,7 @@
, DeriveDataTypeable
, MultiParamTypeClasses
, FlexibleContexts
+ , FlexibleInstances
, CPP
, Rank2Types
, UndecidableInstances
@@ -13,10 +14,10 @@
{-# LANGUAGE Trustworthy #-}
#endif
----------------------------------------------------------------
--- 2013.05.29
+-- 2014.03.07
-- |
-- Module : Data.Number.Fin.Int32
--- Copyright : 2012--2013 wren ng thornton
+-- Copyright : 2012--2014 wren ng thornton
-- License : BSD3
-- Maintainer : wren@community.haskell.org
-- Stability : experimental
@@ -78,6 +79,9 @@ import Data.Reflection (Reifies(reflect), reify)
import Control.Monad (liftM)
import qualified Test.QuickCheck as QC
+#if (MIN_VERSION_smallcheck(1,0,0))
+import Test.SmallCheck.Series ((>>-))
+#endif
#if (MIN_VERSION_smallcheck(0,6,0))
import qualified Test.SmallCheck.Series as SC
#else
@@ -464,7 +468,31 @@ instance (NatLE n MaxBoundInt32, Nat n) => QC.Arbitrary (Fin n) where
instance (NatLE n MaxBoundInt32, Nat n) => QC.CoArbitrary (Fin n) where
coarbitrary (Fin n) = QC.variant n
+#if (MIN_VERSION_smallcheck(1,0,0))
+instance (NatLE n MaxBoundInt32, Nat n, Monad m) => SC.Serial m (Fin n) where
+ -- SC.series :: Series m (Fin n)
+ series = SC.generate $ \d ->
+ if d < 0
+ then [] -- paranoia.
+ else
+ case toFin (fromIntegral d) of
+ Nothing -> enumFromTo minBound maxBound
+ Just n -> enumFromTo minBound n
+
+instance (NatLE n MaxBoundInt32, Nat n, Monad m) => SC.CoSerial m (Fin n) where
+ -- SC.coseries :: Series m b -> Series m (Fin n -> b)
+ coseries rs =
+ SC.alts0 rs >>- \z ->
+ SC.alts1 rs >>- \f ->
+ return $ \(Fin i) ->
+ if i > 0
+ then
+ let j = Fin (i-1) :: Fin n
+ in f j `checking` j -- more paranoia; in case n==0 or i>n
+ else z
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
instance (NatLE n MaxBoundInt32, Nat n) => SC.Serial (Fin n) where
series d
| d < 0 = [] -- paranoia.
@@ -482,9 +510,17 @@ instance (NatLE n MaxBoundInt32, Nat n) => SC.Serial (Fin n) where
| z <- SC.alts0 rs d
, f <- SC.alts1 rs d
]
+#endif
instance (NatLE n MaxBoundInt32, Nat n) => LSC.Serial (Fin n) where
+ -- LSC.series :: Series (Fin n)
+ -- LSC.series :: Int -> Cons (Fin n)
+#if (MIN_VERSION_smallcheck(1,0,0))
+ series = LSC.drawnFrom . (`SC.list` SC.series)
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
series = LSC.drawnFrom . SC.series
+#endif
----------------------------------------------------------------
diff --git a/src/Data/Number/Fin/Int64.hs b/src/Data/Number/Fin/Int64.hs
index 2b748ce..5f6e5a6 100644
--- a/src/Data/Number/Fin/Int64.hs
+++ b/src/Data/Number/Fin/Int64.hs
@@ -3,6 +3,7 @@
, DeriveDataTypeable
, MultiParamTypeClasses
, FlexibleContexts
+ , FlexibleInstances
, CPP
, Rank2Types
, UndecidableInstances
@@ -13,10 +14,10 @@
{-# LANGUAGE Trustworthy #-}
#endif
----------------------------------------------------------------
--- 2013.05.29
+-- 2014.03.07
-- |
-- Module : Data.Number.Fin.Int64
--- Copyright : 2012--2013 wren ng thornton
+-- Copyright : 2012--2014 wren ng thornton
-- License : BSD3
-- Maintainer : wren@community.haskell.org
-- Stability : experimental
@@ -78,6 +79,9 @@ import Data.Reflection (Reifies(reflect), reify)
import Control.Monad (liftM)
import qualified Test.QuickCheck as QC
+#if (MIN_VERSION_smallcheck(1,0,0))
+import Test.SmallCheck.Series ((>>-))
+#endif
#if (MIN_VERSION_smallcheck(0,6,0))
import qualified Test.SmallCheck.Series as SC
#else
@@ -464,7 +468,31 @@ instance (NatLE n MaxBoundInt64, Nat n) => QC.Arbitrary (Fin n) where
instance (NatLE n MaxBoundInt64, Nat n) => QC.CoArbitrary (Fin n) where
coarbitrary (Fin n) = QC.variant n
+#if (MIN_VERSION_smallcheck(1,0,0))
+instance (NatLE n MaxBoundInt64, Nat n, Monad m) => SC.Serial m (Fin n) where
+ -- SC.series :: Series m (Fin n)
+ series = SC.generate $ \d ->
+ if d < 0
+ then [] -- paranoia.
+ else
+ case toFin (fromIntegral d) of
+ Nothing -> enumFromTo minBound maxBound
+ Just n -> enumFromTo minBound n
+
+instance (NatLE n MaxBoundInt64, Nat n, Monad m) => SC.CoSerial m (Fin n) where
+ -- SC.coseries :: Series m b -> Series m (Fin n -> b)
+ coseries rs =
+ SC.alts0 rs >>- \z ->
+ SC.alts1 rs >>- \f ->
+ return $ \(Fin i) ->
+ if i > 0
+ then
+ let j = Fin (i-1) :: Fin n
+ in f j `checking` j -- more paranoia; in case n==0 or i>n
+ else z
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
instance (NatLE n MaxBoundInt64, Nat n) => SC.Serial (Fin n) where
series d
| d < 0 = [] -- paranoia.
@@ -482,9 +510,17 @@ instance (NatLE n MaxBoundInt64, Nat n) => SC.Serial (Fin n) where
| z <- SC.alts0 rs d
, f <- SC.alts1 rs d
]
+#endif
instance (NatLE n MaxBoundInt64, Nat n) => LSC.Serial (Fin n) where
+ -- LSC.series :: Series (Fin n)
+ -- LSC.series :: Int -> Cons (Fin n)
+#if (MIN_VERSION_smallcheck(1,0,0))
+ series = LSC.drawnFrom . (`SC.list` SC.series)
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
series = LSC.drawnFrom . SC.series
+#endif
----------------------------------------------------------------
diff --git a/src/Data/Number/Fin/Int8.hs b/src/Data/Number/Fin/Int8.hs
index aa5c856..bc7618d 100644
--- a/src/Data/Number/Fin/Int8.hs
+++ b/src/Data/Number/Fin/Int8.hs
@@ -3,6 +3,7 @@
, DeriveDataTypeable
, MultiParamTypeClasses
, FlexibleContexts
+ , FlexibleInstances
, CPP
, Rank2Types
, UndecidableInstances
@@ -13,10 +14,10 @@
{-# LANGUAGE Trustworthy #-}
#endif
----------------------------------------------------------------
--- 2013.05.29
+-- 2014.03.07
-- |
-- Module : Data.Number.Fin.Int8
--- Copyright : 2012--2013 wren ng thornton
+-- Copyright : 2012--2014 wren ng thornton
-- License : BSD3
-- Maintainer : wren@community.haskell.org
-- Stability : experimental
@@ -78,6 +79,9 @@ import Data.Reflection (Reifies(reflect), reify)
import Control.Monad (liftM)
import qualified Test.QuickCheck as QC
+#if (MIN_VERSION_smallcheck(1,0,0))
+import Test.SmallCheck.Series ((>>-))
+#endif
#if (MIN_VERSION_smallcheck(0,6,0))
import qualified Test.SmallCheck.Series as SC
#else
@@ -465,14 +469,43 @@ instance (NatLE n MaxBoundInt8, Nat n) => QC.CoArbitrary (Fin n) where
coarbitrary (Fin n) = QC.variant n
+#if (MIN_VERSION_smallcheck(1,0,0))
+instance (NatLE n MaxBoundInt8, Nat n, Monad m) => SC.Serial m (Fin n) where
+ -- SC.series :: Series m (Fin n)
+ series = SC.generate $ \d ->
+ if d < 0
+ then [] -- paranoia.
+ else
+ case toFin (fromIntegral d) of
+ Nothing -> enumFromTo minBound maxBound
+ Just n -> enumFromTo minBound n
+
+instance (NatLE n MaxBoundInt8, Nat n, Monad m) => SC.CoSerial m (Fin n) where
+ -- SC.coseries :: Series m b -> Series m (Fin n -> b)
+ coseries rs =
+ SC.alts0 rs >>- \z ->
+ SC.alts1 rs >>- \f ->
+ return $ \(Fin i) ->
+ if i > 0
+ then
+ let j = Fin (i-1) :: Fin n
+ in f j `checking` j -- more paranoia; in case n==0 or i>n
+ else z
+
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
instance (NatLE n MaxBoundInt8, Nat n) => SC.Serial (Fin n) where
+ -- SC.series :: Series (Fin n)
+ -- SC.series :: Int -> [Fin n]
series d
| d < 0 = [] -- paranoia.
| otherwise =
case toFin (fromIntegral d) of
Nothing -> enumFromTo minBound maxBound
Just n -> enumFromTo minBound n
-
+
+ -- SC.coseries :: Series b -> Series (Fin n -> b)
+ -- SC.coseries :: (Int -> [b]) -> (Int -> [Fin n -> b])
coseries rs d =
[ \(Fin i) ->
if i > 0
@@ -482,9 +515,17 @@ instance (NatLE n MaxBoundInt8, Nat n) => SC.Serial (Fin n) where
| z <- SC.alts0 rs d
, f <- SC.alts1 rs d
]
+#endif
instance (NatLE n MaxBoundInt8, Nat n) => LSC.Serial (Fin n) where
+ -- LSC.series :: Series (Fin n)
+ -- LSC.series :: Int -> Cons (Fin n)
+#if (MIN_VERSION_smallcheck(1,0,0))
+ series = LSC.drawnFrom . (`SC.list` SC.series)
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
series = LSC.drawnFrom . SC.series
+#endif
----------------------------------------------------------------
diff --git a/src/Data/Number/Fin/Integer.hs b/src/Data/Number/Fin/Integer.hs
index 835d6fe..3a20c30 100644
--- a/src/Data/Number/Fin/Integer.hs
+++ b/src/Data/Number/Fin/Integer.hs
@@ -3,6 +3,7 @@
, DeriveDataTypeable
, MultiParamTypeClasses
, FlexibleContexts
+ , FlexibleInstances
, CPP
, Rank2Types
#-}
@@ -12,10 +13,10 @@
{-# LANGUAGE Trustworthy #-}
#endif
----------------------------------------------------------------
--- 2013.07.20
+-- 2014.03.07
-- |
-- Module : Data.Number.Fin.Integer
--- Copyright : 2012--2013 wren ng thornton
+-- Copyright : 2012--2014 wren ng thornton
-- License : BSD3
-- Maintainer : wren@community.haskell.org
-- Stability : experimental
@@ -76,6 +77,10 @@ import Data.Reflection (Reifies(reflect), reify)
import Control.Monad (liftM)
import qualified Test.QuickCheck as QC
+
+#if (MIN_VERSION_smallcheck(1,0,0))
+import Test.SmallCheck.Series ((>>-))
+#endif
#if (MIN_VERSION_smallcheck(0,6,0))
import qualified Test.SmallCheck.Series as SC
#else
@@ -465,7 +470,31 @@ instance Nat n => QC.Arbitrary (Fin n) where
instance Nat n => QC.CoArbitrary (Fin n) where
coarbitrary (Fin n) = QC.variant n
+#if (MIN_VERSION_smallcheck(1,0,0))
+instance (Nat n, Monad m) => SC.Serial m (Fin n) where
+ -- SC.series :: Series m (Fin n)
+ series = SC.generate $ \d ->
+ if d < 0
+ then [] -- paranoia.
+ else
+ case toFin (toInteger d) of
+ Nothing -> enumFromTo minBound maxBound
+ Just n -> enumFromTo minBound n
+instance (Nat n, Monad m) => SC.CoSerial m (Fin n) where
+ -- SC.coseries :: Series m b -> Series m (Fin n -> b)
+ coseries rs =
+ SC.alts0 rs >>- \z ->
+ SC.alts1 rs >>- \f ->
+ return $ \(Fin i) ->
+ if i > 0
+ then
+ let j = Fin (i-1) :: Fin n
+ in f j `checking` j -- more paranoia; in case n==0 or i>n
+ else z
+
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
instance Nat n => SC.Serial (Fin n) where
series d
| d < 0 = [] -- paranoia.
@@ -483,9 +512,17 @@ instance Nat n => SC.Serial (Fin n) where
| z <- SC.alts0 rs d
, f <- SC.alts1 rs d
]
+#endif
instance Nat n => LSC.Serial (Fin n) where
+ -- LSC.series :: Series (Fin n)
+ -- LSC.series :: Int -> Cons (Fin n)
+#if (MIN_VERSION_smallcheck(1,0,0))
+ series = LSC.drawnFrom . (`SC.list` SC.series)
+#else
+-- (MAX_VERSION_smallcheck(0,6,2))
series = LSC.drawnFrom . SC.series
+#endif
----------------------------------------------------------------