utility-ht 0.0.16 → 0.0.17
raw patch · 6 files changed
+100/−28 lines, 6 filesdep ~doctest-lib
Dependency ranges changed: doctest-lib
Files
- Makefile +1/−1
- src/Data/List/HT.hs +1/−0
- src/Data/List/HT/Private.hs +45/−4
- src/Data/Ord/HT.hs +2/−0
- src/DocTest/Data/List/HT/Private.hs +47/−19
- utility-ht.cabal +4/−4
Makefile view
@@ -15,4 +15,4 @@ runhaskell Setup test --show-details=streaming update-test:- doctest-extract -i src/ -o src/ --module-prefix DocTest --executable-main=Test.hs --import-tested $$(cat test-module.list)+ doctest-extract-0.1 -i src/ -o src/ --module-prefix DocTest --executable-main=Test.hs --import-tested $$(cat test-module.list)
src/Data/List/HT.hs view
@@ -62,6 +62,7 @@ L.isAscendingLazy, L.mapAdjacent, L.mapAdjacent1,+ L.equalWith, L.range, L.padLeft, L.padRight,
src/Data/List/HT/Private.hs view
@@ -5,7 +5,7 @@ import Data.Maybe as Maybe (fromMaybe, catMaybes, isJust, mapMaybe, ) import Data.Maybe.HT (toMaybe, ) import Control.Monad.HT ((<=<), )-import Control.Monad (guard, msum, mplus, )+import Control.Monad (guard, msum, mplus, liftM2, ) import Control.Applicative ((<$>), (<*>), ) import Data.Tuple.HT (mapPair, mapFst, mapSnd, forcePair, swap, ) @@ -952,11 +952,11 @@ (b -> a -> b) -> b -> (c -> d -> d) -> d -> [(a,c)] -> (b,d) foldl'r f b0 g d0 = -- (\(k,d1) -> (k b0, d1)) .- mapFst ($b0) .+ mapFst ($ b0) . foldr (\(a,c) ~(k,d) -> (\b -> k $! f b a, g c d)) (id,d0) foldl'rStrict f b0 g d0 =- mapFst ($b0) .+ mapFst ($ b0) . foldr (\(a,c) ~(k,d) -> ((,) $! (\b -> k $! f b a)) $! g c d) (id,d0) foldl'rNaive f b g d xs =@@ -1074,7 +1074,7 @@ {- | more efficient implementation of rotate' -prop> \(NonNegative n) (NonEmpty xs) -> rotate n xs == rotate' n (xs::String)+prop> \n (NonEmpty xs) -> rotate n xs == rotate' n (xs::String) -} rotate' n x = uncurry (flip (++))@@ -1167,6 +1167,47 @@ mapAdjacent1 :: (a -> a -> b -> c) -> a -> [(a,b)] -> [c] mapAdjacent1 f a xs = zipWith (\a0 (a1,b) -> f a0 a1 b) (a : map fst xs) xs+++{- |+>>> equalWith (<=) "ab" "bb"+True+>>> equalWith (<=) "aa" "bbb"+False+>>> equalWith (==) "aa" "aaa"+False++prop> \as bs -> let f a b = abs (a-b) <= (10::Int) in equalWith f as bs == equalWithRec f as bs+prop> \as bs -> let f a b = abs (a-b) <= (10::Int) in equalWith f as bs == equalWithLiftM f as bs+-}+equalWith, equalWithLiftM, equalWithRec ::+ (a -> b -> Bool) -> [a] -> [b] -> Bool+equalWith f as bs =+ and $+ zipWith+ (\ma mb ->+ case (ma,mb) of+ (Just a, Just b) -> f a b+ (Nothing, Nothing) -> True+ _ -> False)+ (map Just as ++ [Nothing])+ (map Just bs ++ [Nothing])++equalWithLiftM f as bs =+ all (Just True ==) $+ zipWith+ (\ma mb ->+ case (ma,mb) of+ (Nothing, Nothing) -> Just True+ _ -> liftM2 f ma mb)+ (map Just as ++ [Nothing])+ (map Just bs ++ [Nothing])++equalWithRec f =+ let go (a:as) (b:bs) = f a b && go as bs+ go [] [] = True+ go _ _ = False+ in go {- |
src/Data/Ord/HT.hs view
@@ -9,6 +9,8 @@ {- | @limit (lower,upper) x@ restricts @x@ to the range from @lower@ to @upper@. Don't expect a sensible result for @lower>upper@.++Called @clamp@ elsewhere. -} {-# INLINE limit #-} limit :: (Ord a) => (a,a) -> a -> a
src/DocTest/Data/List/HT/Private.hs view
@@ -505,7 +505,7 @@ {-# LINE 1077 "src/Data/List/HT/Private.hs" #-} DocTest.property {-# LINE 1077 "src/Data/List/HT/Private.hs" #-}- (\(NonNegative n) (NonEmpty xs) -> rotate n xs == rotate' n (xs::String))+ (\n (NonEmpty xs) -> rotate n xs == rotate' n (xs::String)) DocTest.printPrefix "Data.List.HT.Private:1084: " {-# LINE 1084 "src/Data/List/HT/Private.hs" #-} DocTest.property@@ -623,36 +623,64 @@ {-# LINE 1164 "src/Data/List/HT/Private.hs" #-} (let f x y z = [x,y]++show(z::Int) in mapAdjacent1 f 'a' [('b',1), ('c',2), ('d',3)]) [ExpectedLine [LineChunk "[\"ab1\",\"bc2\",\"cd3\"]"]]- DocTest.printPrefix "Data.List.HT.Private:1183: "-{-# LINE 1183 "src/Data/List/HT/Private.hs" #-}+ DocTest.printPrefix "Data.List.HT.Private:1180: "+{-# LINE 1180 "src/Data/List/HT/Private.hs" #-} DocTest.property-{-# LINE 1183 "src/Data/List/HT/Private.hs" #-}+{-# LINE 1180 "src/Data/List/HT/Private.hs" #-}+ (\as bs -> let f a b = abs (a-b) <= (10::Int) in equalWith f as bs == equalWithRec f as bs)+ DocTest.printPrefix "Data.List.HT.Private:1181: "+{-# LINE 1181 "src/Data/List/HT/Private.hs" #-}+ DocTest.property+{-# LINE 1181 "src/Data/List/HT/Private.hs" #-}+ (\as bs -> let f a b = abs (a-b) <= (10::Int) in equalWith f as bs == equalWithLiftM f as bs)+ DocTest.printPrefix "Data.List.HT.Private:1173: "+{-# LINE 1173 "src/Data/List/HT/Private.hs" #-}+ DocTest.example+{-# LINE 1173 "src/Data/List/HT/Private.hs" #-}+ (equalWith (<=) "ab" "bb")+ [ExpectedLine [LineChunk "True"]]+ DocTest.printPrefix "Data.List.HT.Private:1175: "+{-# LINE 1175 "src/Data/List/HT/Private.hs" #-}+ DocTest.example+{-# LINE 1175 "src/Data/List/HT/Private.hs" #-}+ (equalWith (<=) "aa" "bbb")+ [ExpectedLine [LineChunk "False"]]+ DocTest.printPrefix "Data.List.HT.Private:1177: "+{-# LINE 1177 "src/Data/List/HT/Private.hs" #-}+ DocTest.example+{-# LINE 1177 "src/Data/List/HT/Private.hs" #-}+ (equalWith (==) "aa" "aaa")+ [ExpectedLine [LineChunk "False"]]+ DocTest.printPrefix "Data.List.HT.Private:1224: "+{-# LINE 1224 "src/Data/List/HT/Private.hs" #-}+ DocTest.property+{-# LINE 1224 "src/Data/List/HT/Private.hs" #-} (\(NonNegative n) -> length (range n :: [Integer]) == n)- DocTest.printPrefix "Data.List.HT.Private:1176: "-{-# LINE 1176 "src/Data/List/HT/Private.hs" #-}+ DocTest.printPrefix "Data.List.HT.Private:1217: "+{-# LINE 1217 "src/Data/List/HT/Private.hs" #-} DocTest.example-{-# LINE 1176 "src/Data/List/HT/Private.hs" #-}+{-# LINE 1217 "src/Data/List/HT/Private.hs" #-} (range 0 :: [Integer]) [ExpectedLine [LineChunk "[]"]]- DocTest.printPrefix "Data.List.HT.Private:1178: "-{-# LINE 1178 "src/Data/List/HT/Private.hs" #-}+ DocTest.printPrefix "Data.List.HT.Private:1219: "+{-# LINE 1219 "src/Data/List/HT/Private.hs" #-} DocTest.example-{-# LINE 1178 "src/Data/List/HT/Private.hs" #-}+{-# LINE 1219 "src/Data/List/HT/Private.hs" #-} (range 1 :: [Integer]) [ExpectedLine [LineChunk "[0]"]]- DocTest.printPrefix "Data.List.HT.Private:1180: "-{-# LINE 1180 "src/Data/List/HT/Private.hs" #-}+ DocTest.printPrefix "Data.List.HT.Private:1221: "+{-# LINE 1221 "src/Data/List/HT/Private.hs" #-} DocTest.example-{-# LINE 1180 "src/Data/List/HT/Private.hs" #-}+{-# LINE 1221 "src/Data/List/HT/Private.hs" #-} (range 8 :: [Integer]) [ExpectedLine [LineChunk "[0,1,2,3,4,5,6,7]"]]- DocTest.printPrefix "Data.List.HT.Private:1210: "-{-# LINE 1210 "src/Data/List/HT/Private.hs" #-}+ DocTest.printPrefix "Data.List.HT.Private:1251: "+{-# LINE 1251 "src/Data/List/HT/Private.hs" #-} DocTest.property-{-# LINE 1210 "src/Data/List/HT/Private.hs" #-}+{-# LINE 1251 "src/Data/List/HT/Private.hs" #-} (\x -> equating (take 1000) (List.iterate (x+) x) (iterateAssociative (+) (x::Integer)))- DocTest.printPrefix "Data.List.HT.Private:1229: "-{-# LINE 1229 "src/Data/List/HT/Private.hs" #-}+ DocTest.printPrefix "Data.List.HT.Private:1270: "+{-# LINE 1270 "src/Data/List/HT/Private.hs" #-} DocTest.property-{-# LINE 1229 "src/Data/List/HT/Private.hs" #-}+{-# LINE 1270 "src/Data/List/HT/Private.hs" #-} (\x -> equating (take 1000) (List.iterate (x+) x) (iterateLeaky (+) (x::Integer)))
utility-ht.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: 2.2 Name: utility-ht-Version: 0.0.16+Version: 0.0.17 License: BSD-3-Clause License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de>@@ -23,8 +23,8 @@ However, further splitting the base package might invalidate this statement. . Alternative packages: @Useful@, @MissingH@-Tested-With: GHC==7.0.2, GHC==7.2.2, GHC==7.4.1, GHC==7.8.2-Tested-With: GHC==8.6.5+Tested-With: GHC==7.0.2, GHC==7.2.2, GHC==7.4.2, GHC==7.8.4+Tested-With: GHC==8.6.5, GHC==9.4.5, GHC==9.6.1 Build-Type: Simple Stability: Stable @@ -39,7 +39,7 @@ Source-Repository this type: darcs location: http://code.haskell.org/~thielema/utility/- tag: 0.0.16+ tag: 0.0.17 Library Build-Depends: