smallcheck-series 0.3 → 0.4
raw patch · 4 files changed
+61/−7 lines, 4 files
Files
- CHANGELOG.md +9/−3
- Test/SmallCheck/Series/Instances.hs +41/−1
- smallcheck-series.cabal +6/−3
- tests/doctests.hs +5/−0
CHANGELOG.md view
@@ -4,8 +4,13 @@ CHANGELOG](http://keepachangelog.com/). This project adheres to [Semantic Versioning](http://semver.org/). -## [0.3] - 2015-5-25+## [0.4] - 2015-08-06 ### Added+- Support for stack.+- `CoSerial` instances.++## [0.3] - 2015-05-25+### Added - Serial instance for `Map`. - `zipLogic` for *zipping* instances. Thanks to Roman Cheplyaka [@feuerbach](https://github.com/feuerbach).@@ -13,18 +18,19 @@ ### Fixed - Compatibility with GHC < 7.10. -## [0.2] - 2015-4-28+## [0.2] - 2015-04-28 ### Changed - General renaming to, hopefully, make functions more clear. ### Fixed - Series don't repeat elements anymore. Kudos to Roman Cheplyaka for reporting this issue. -## [0.1] - 2015-4-27+## [0.1] - 2015-04-27 ### Added - Initial set of utilities for creating `ByteString` and `Text` `Series`. - `Serial` `ByteString` and `Text` instances. +[0.4]: https://github.com/jdnavarro/smallcheck-series/compare/v0.3...v0.4 [0.3]: https://github.com/jdnavarro/smallcheck-series/compare/v0.2...v0.3 [0.2]: https://github.com/jdnavarro/smallcheck-series/compare/v0.1...v0.2 [0.1]: https://github.com/jdnavarro/smallcheck-series/compare/49b5b0...v0.1
Test/SmallCheck/Series/Instances.hs view
@@ -27,6 +27,7 @@ import qualified Data.ByteString.Lazy as BL import qualified Data.Text as T import qualified Data.Text.Lazy as TL+import Data.Map import qualified Data.Map as Map import Test.SmallCheck.Series @@ -38,15 +39,54 @@ instance Monad m => Serial m B.ByteString where series = Series.ByteString.replicateA+instance Monad m => CoSerial m B.ByteString where+ coseries rs =+ alts0 rs >>- \y ->+ alts2 rs >>- \f ->+ return $ \bs -> case B.uncons bs of+ Nothing -> y+ Just (b,bs') -> f (B.singleton b) bs' instance Monad m => Serial m BL.ByteString where series = Series.ByteString.Lazy.replicateA+instance Monad m => CoSerial m BL.ByteString where+ coseries rs =+ alts0 rs >>- \y ->+ alts2 rs >>- \f ->+ return $ \bs -> case BL.uncons bs of+ Nothing -> y+ Just (b,bs') -> f (BL.singleton b) bs' instance Monad m => Serial m T.Text where series = Series.Text.replicateA+instance Monad m => CoSerial m T.Text where+ coseries rs =+ alts0 rs >>- \y ->+ alts2 rs >>- \f ->+ return $ \bs -> case T.uncons bs of+ Nothing -> y+ Just (b,bs') -> f (T.singleton b) bs' instance Monad m => Serial m TL.Text where series = Series.Text.Lazy.replicateA+instance Monad m => CoSerial m TL.Text where+ coseries rs =+ alts0 rs >>- \y ->+ alts2 rs >>- \f ->+ return $ \bs -> case TL.uncons bs of+ Nothing -> y+ Just (b,bs') -> f (TL.singleton b) bs' -instance (Serial m k, Serial m v) => Serial m (Map.Map k v) where+instance (Serial m k, Serial m v) => Serial m (Map k v) where series = Map.singleton <$> series <~> series+instance (Ord k, CoSerial m k, CoSerial m v) => CoSerial m (Map k v) where+ coseries rs =+ alts0 rs >>- \y ->+ alts2 rs >>- \f ->+ return $ \m -> case pop m of+ Nothing -> y+ Just ((k,v), m') -> f (Map.singleton k v) m'+ where+ pop m = case Map.toList m of+ [] -> Nothing+ (kv:its) -> Just (kv, Map.fromList its)
smallcheck-series.cabal view
@@ -1,9 +1,12 @@ name: smallcheck-series-version: 0.3+version: 0.4 synopsis: Extra SmallCheck series and utilities description:- Orphan @Serial@ instances and utilities to create and manipulate- @Series@ for common types.+ Orphan+ @<https://hackage.haskell.org/package/smallcheck-1.1.1/docs/Test-SmallCheck-Series.html#t:Serial Serial>@+ instances and utilities to create and manipulate+ @<https://hackage.haskell.org/package/smallcheck-1.1.1/docs/Test-SmallCheck-Series.html#t:Series Series>@+ for common types. homepage: https://github.com/jdnavarro/smallcheck-series bug-reports: https://github.com/jdnavarro/smallcheck-series/issues license: BSD3
tests/doctests.hs view
@@ -1,10 +1,15 @@+{-# LANGUAGE CPP #-} module Main where import System.FilePath.Glob (glob) import Test.DocTest (doctest) main :: IO ()+#if !MIN_VERSION_doctest(0,10,1) main = doctest . ([ "-idist/build/autogen" , "-optP-include" , "-optPdist/build/autogen/cabal_macros.h" ] ++) =<< glob "Test/**/*.hs"+#else+main = doctest =<< glob "Test/**/*.hs"+#endif