data-fin 0.1.0 → 0.1.1
raw patch · 9 files changed
+213/−20 lines, 9 filesdep ~reflectiondep ~smallcheckdep ~tagged
Dependency ranges changed: reflection, smallcheck, tagged
Files
- LICENSE +1/−1
- README +1/−1
- VERSION +2/−0
- data-fin.cabal +7/−7
- src/Data/Number/Fin/Int16.hs +43/−2
- src/Data/Number/Fin/Int32.hs +38/−2
- src/Data/Number/Fin/Int64.hs +38/−2
- src/Data/Number/Fin/Int8.hs +44/−3
- src/Data/Number/Fin/Integer.hs +39/−2
LICENSE view
@@ -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
README view
@@ -30,7 +30,7 @@ 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
VERSION view
@@ -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
data-fin.cabal view
@@ -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 @@ 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 @@ 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 @@ -- 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
src/Data/Number/Fin/Int16.hs view
@@ -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 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 @@ 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 @@ 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 @@ | 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 ----------------------------------------------------------------
src/Data/Number/Fin/Int32.hs view
@@ -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 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.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 @@ | 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 ----------------------------------------------------------------
src/Data/Number/Fin/Int64.hs view
@@ -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 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.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 @@ | 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 ----------------------------------------------------------------
src/Data/Number/Fin/Int8.hs view
@@ -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 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 @@ 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 @@ | 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 ----------------------------------------------------------------
src/Data/Number/Fin/Integer.hs view
@@ -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 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.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 @@ | 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 ----------------------------------------------------------------