deferred-folds 0.9.8 → 0.9.9
raw patch · 3 files changed
+60/−2 lines, 3 filesdep +QuickCheckdep +deferred-foldsdep +quickcheck-instancesPVP ok
version bump matches the API change (PVP)
Dependencies added: QuickCheck, deferred-folds, quickcheck-instances, rerebase, tasty, tasty-hunit, tasty-quickcheck
API changes (from Hackage documentation)
+ DeferredFolds.Unfoldr: take :: Int -> Unfoldr a -> Unfoldr a
+ DeferredFolds.Unfoldr: takeWhile :: (a -> Bool) -> Unfoldr a -> Unfoldr a
Files
- deferred-folds.cabal +18/−2
- library/DeferredFolds/Defs/Unfoldr.hs +15/−0
- test/Main.hs +27/−0
deferred-folds.cabal view
@@ -1,5 +1,5 @@ name: deferred-folds-version: 0.9.8+version: 0.9.9 category: Folding synopsis: Abstractions over deferred folds description:@@ -37,7 +37,7 @@ DeferredFolds.Defs.UnfoldrM DeferredFolds.Prelude build-depends:- base >=4.7 && <5,+ base >=4.9 && <5, bytestring >=0.10 && <0.11, containers >=0.5 && <0.6, foldl >=1 && <2,@@ -46,3 +46,19 @@ transformers >=0.5 && <0.6, unordered-containers >=0.2 && <0.3, vector >=0.12 && <0.13++test-suite test+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ default-extensions: Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, PatternSynonyms, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples+ default-language: Haskell2010+ main-is:+ Main.hs+ build-depends:+ deferred-folds,+ QuickCheck >=2.8.1 && <3,+ quickcheck-instances >=0.3.11 && <0.4,+ rerebase <2,+ tasty >=0.12 && <2,+ tasty-hunit >=0.9 && <0.11,+ tasty-quickcheck >=0.9 && <0.11
library/DeferredFolds/Defs/Unfoldr.hs view
@@ -298,3 +298,18 @@ else step index (loop (succ index)) else state in loop 0++take :: Int -> Unfoldr a -> Unfoldr a+take amount (Unfoldr unfoldr) = Unfoldr $ \ step init -> unfoldr+ (\ a nextState index -> if index < amount+ then step a (nextState (succ index))+ else init)+ (const init)+ 0++takeWhile :: (a -> Bool) -> Unfoldr a -> Unfoldr a+takeWhile predicate (Unfoldr unfoldr) = Unfoldr $ \ step init -> unfoldr+ (\ a nextState -> if predicate a+ then step a nextState+ else init)+ init
+ test/Main.hs view
@@ -0,0 +1,27 @@+module Main where++import Prelude+import Test.QuickCheck.Instances+import Test.Tasty+import Test.Tasty.Runners+import Test.Tasty.HUnit+import Test.Tasty.QuickCheck+import qualified Test.QuickCheck as QuickCheck+import qualified Test.QuickCheck.Property as QuickCheck+import qualified DeferredFolds.Unfoldr as Unfoldr+++main =+ defaultMain $+ testGroup "All" $ [+ testProperty "List roundtrip" $ \ (list :: [Int]) ->+ list === toList (Unfoldr.foldable list)+ ,+ testProperty "take" $ \ (list :: [Int], amount) ->+ take amount list ===+ toList (Unfoldr.take amount (Unfoldr.foldable list))+ ,+ testProperty "takeWhile odd" $ \ (list :: [Int]) ->+ takeWhile odd list ===+ toList (Unfoldr.takeWhile odd (Unfoldr.foldable list))+ ]