packages feed

utility-ht 0.0.8 → 0.0.9

raw patch · 8 files changed

+91/−6 lines, 8 files

Files

src/Control/Monad/HT.hs view
@@ -67,3 +67,7 @@    if b      then return True      else m1+++void :: (Monad m) => m a -> m ()+void = liftM (const ())
src/Data/Function/HT/Private.hs view
@@ -43,3 +43,18 @@  powerAssociative1 op a0 a n =    foldr op a0 (genericReplicate n a)+++infixl 0 $%++{- |+Flipped version of '($)'.++It was discussed as (&) in+http://www.haskell.org/pipermail/libraries/2012-November/018832.html++I am not sure, that we need it.+It is not exported for now.+-}+($%) :: a -> (a -> b) -> b+($%) = flip ($)
src/Data/List/HT/Private.hs view
@@ -50,7 +50,7 @@    uncurry (:) $    case xt of       [] -> ([],[])-      xxs@(_:xs) -> (xxs, tails xs)+      _:xs -> (xt, tails xs)  tails' :: [a] -> [[a]] tails' = fst . breakAfter null . iterate tail@@ -248,6 +248,26 @@          in  if p x then ([],xs:ys) else (xs,ys))       ([],[]) +segmentBefore' :: (a -> Bool) -> [a] -> [[a]]+segmentBefore' p =+   uncurry (:) .+   (\xst ->+      fromMaybe ([],xst) $ do+         ((x:xs):xss) <- Just xst+         guard $ not $ p x+         return (x:xs, xss)) .+   groupBy (\_ x -> not $ p x)++segmentBefore'' :: (a -> Bool) -> [a] -> [[a]]+segmentBefore'' p =+   (\xst ->+      case xst of+         ~(xs:xss) ->+            tail xs : xss) .+   groupBy (\_ x -> not $ p x) .+   (error "segmentBefore: dummy element" :)++ propSegmentBeforeConcat :: Eq a => (a -> Bool) -> [a] -> Bool propSegmentBeforeConcat p xs =    concat (segmentBefore p xs) == xs@@ -267,6 +287,14 @@ propSegmentBeforeInfinite :: (a -> Bool) -> a -> [a] -> Bool propSegmentBeforeInfinite p x =    flip seq True . (!!100) . concat . segmentBefore p . cycle . (x:)++propSegmentBeforeGroupBy0 :: Eq a => (a -> Bool) -> [a] -> Bool+propSegmentBeforeGroupBy0 p xs =+   segmentBefore p xs == segmentBefore' p xs++propSegmentBeforeGroupBy1 :: Eq a => (a -> Bool) -> [a] -> Bool+propSegmentBeforeGroupBy1 p xs =+   segmentBefore p xs == segmentBefore'' p xs   -- cf. Matroid.hs
src/Data/List/Match.hs view
@@ -3,6 +3,7 @@    L.drop,    L.splitAt,    L.replicate,+   L.equalLength,    L.compareLength,    L.lessOrEqualLength,    L.shorterList,
src/Data/List/Match/Private.hs view
@@ -69,6 +69,14 @@   {- |+Check whether two lists with different element types have equal length.+It is equivalent to @length xs == length ys@ but more efficient.+-}+equalLength :: [a] -> [b] -> Bool+equalLength xs ys =+   void xs == void ys++{- | Compare the length of two lists over different types. It is equivalent to @(compare (length xs) (length ys))@ but more efficient.@@ -104,7 +112,7 @@ {- | Returns the shorter one of two lists. It works also for infinite lists as much as possible.-E.g. @shortList (shorterList (repeat 1) (repeat 2)) [1,2,3]@+E.g. @shorterList (shorterList (repeat 1) (repeat 2)) [1,2,3]@ can be computed. The trick is, that the skeleton of the resulting list is constructed using 'zipWith' without touching the elements.
src/Data/Monoid/HT.hs view
@@ -1,4 +1,4 @@-module Data.Monoid.HT (cycle, ) where+module Data.Monoid.HT (cycle, (<>), ) where  import Data.Monoid (Monoid, mappend, ) import Data.Function (fix, )@@ -12,3 +12,12 @@ cycle :: Monoid m => m -> m cycle x =    fix (mappend x)+++infixr 6 <>++{- |+Infix synonym for 'mappend.+-}+(<>) :: Monoid m => m -> m -> m+(<>) = mappend
src/Data/Tuple/HT.hs view
@@ -50,6 +50,22 @@ thd3 :: (a,b,c) -> c thd3 ~(_,_,x) = x +{-# INLINE mapTriple #-}+mapTriple :: (a -> d, b -> e, c -> f) -> (a,b,c) -> (d,e,f)+mapTriple ~(f,g,h) ~(x,y,z) = (f x, g y, h z)++{-# INLINE mapFst3 #-}+mapFst3 :: (a -> d) -> (a,b,c) -> (d,b,c)+mapFst3 f ~(a,b,c) = (f a, b, c)++{-# INLINE mapSnd3 #-}+mapSnd3 :: (b -> d) -> (a,b,c) -> (a,d,c)+mapSnd3 f ~(a,b,c) = (a, f b, c)++{-# INLINE mapThd3 #-}+mapThd3 :: (c -> d) -> (a,b,c) -> (a,b,d)+mapThd3 f ~(a,b,c) = (a, b, f c)+ {-# INLINE curry3 #-} curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d curry3 f a b c = f (a,b,c)
utility-ht.cabal view
@@ -1,5 +1,5 @@ Name:             utility-ht-Version:          0.0.8+Version:          0.0.9 License:          BSD3 License-File:     LICENSE Author:           Henning Thielemann <haskell@henning-thielemann.de>@@ -11,6 +11,10 @@   Various small helper functions for Lists, Maybes, Tuples, Functions.   Some of these functions are improved implementations of standard functions.   They have the same name as their standard counterparts.+  Others are equivalent to functions from the @base@ package,+  but if you import them from this utility package+  then you can write code that runs on older GHC versions+  or other compilers like Hugs and JHC.   .   All modules are plain Haskell 98.   The package depends exclusively on the @base@ package@@ -20,7 +24,7 @@   .   Alternative packages: @Useful@, @MissingH@ Tested-With:       GHC==6.8.2, GHC==6.10.4, GHC==6.12.3-Tested-With:       GHC==7.0.2, GHC==7.2.2+Tested-With:       GHC==7.0.2, GHC==7.2.2, GHC==7.4.1 Cabal-Version:     >=1.10 Build-Type:        Simple @@ -40,7 +44,7 @@ Source-Repository this   type:     darcs   location: http://code.haskell.org/~thielema/utility/-  tag:      0.0.8+  tag:      0.0.9  Library   Build-Depends: