prelude-generalize 0.3.1 → 0.4
raw patch · 2 files changed
+16/−14 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Prelude.Generalize: reSigned :: (Integral t, Bits t, Integral u, Bits u) => t -> u
+ Prelude.Generalize: snocA :: Alternative f => x -> f x -> f x
- Prelude.Generalize: count :: (Copeanoid i, Alternative f, Alternative g, Traversable g) => i -> f x -> f (g x)
+ Prelude.Generalize: count :: (Copeanoid i, Applicative f, Alternative g, Traversable g) => i -> f x -> f (g x)
Files
- Prelude/Generalize.hs +15/−13
- prelude-generalize.cabal +1/−1
Prelude/Generalize.hs view
@@ -2,20 +2,20 @@ module Prelude.Generalize ( module Control.Applicative, module Control.Monad.Logic, module Prelude, - module Control.Comonad, module Data.Foldable, module Data.Monoid, - bool, (<>>=), (!!), tail, length, filter, consA, liftPair, Peanoid(..), + module Control.Comonad, module Data.Foldable, module Data.Monoid, bool, + (<>>=), (!!), tail, length, filter, consA, snocA, liftPair, Peanoid(..), Copeanoid(..), fair, (++), module Data.Functor.Identity, iterate, church, unfoldr, convList, head, drop, take, find, takeWhile, dropWhile, tails, - findIndex, module Control.Category, module Control.Arrow, option, cycle, - mcycle, repeat, replicate, module Data.Traversable, count, choice, - mreplicate, (>>==), groupBy, lefts, rights, partitionEithers, null, concat, + findIndex, module Control.Category, module Control.Arrow, option, + cycle, mcycle, repeat, replicate, module Data.Traversable, count, choice, + mreplicate, (>>==), groupBy, lefts, rights, partitionEithers, null, unnull, module Data.Bits, module Data.Int, module Data.Word, Swap(..), Peano, atLeast, (.:), (.::), (.:::), bind2, bind3, (!!!), transEnum, transInt, - low8bits, modifyBit, reSigned, getBits, transPeano, Part1M, Part1(..), + low8bits, modifyBit, getBits, transPeano, Part1M, Part1(..), Part2M, Part2(..), Part3M, Part3(..), Part4M, Part4(..), Part5M, Part5(..), Part6M, Part6(..), QuestionMarkOp(..), selectItems, selectBits, hGetByte, hPutByte, module System.IO, (>>=||), (>>=|||), (>>=|\/), (>>=\/), azero, - aplus, unnull, on, sortBy, sort, intersperse, intersperse', intercalate, + aplus, concat, on, sortBy, sort, intersperse, intersperse', intercalate, stripPrefix, stripPrefixBy, isPrefixOf, isSuffixOf, isInfixOf, (\\), nub, nubBy, deleteF, delete, group, insert, insertBy, intersect, intersectBy, partition, permutations, subsequences, transpose, union, unionBy, unzip4, @@ -458,12 +458,12 @@ (!!) :: (Copeanoid i, Foldable t) => t x -> i -> x; x !! n = either id (error "(!!): no element") $ - foldl (\y x -> y >>= maybe (Left x) Right . predP) (Right n) x; + foldlM (\y z -> maybe (Left z) Right (predP y)) n x; {-# RULES "L.!!" (!!) = (L.!!) #-}; (!!!) :: (Copeanoid i, Foldable t, Alternative f) => t x -> i -> f x; x !!! n = either pure (const empty) $ - foldl (\y x -> y >>= maybe (Left x) Right . predP) (Right n) x; + foldlM (\y z -> maybe (Left z) Right (predP y)) n x; length :: (Peanoid i, Foldable t) => t x -> i; length = foldr (const succP) zeroP; @@ -482,6 +482,11 @@ option :: Alternative f => x -> f x -> f x; option x y = y <|> pure x; + snocA :: Alternative f => x -> f x -> f x; + snocA = option; +{-# INLINE snocA #-}; +{-# RULES "snocA" snocA = option #-}; + liftPair :: Applicative f => (f x, f y) -> f (x, y); liftPair = uncurry $ liftA2 (,); @@ -559,7 +564,7 @@ mreplicate :: (Copeanoid i, Monoid x) => i -> x -> x; mreplicate i x = maybe mempty (\z -> mappend x $ mreplicate z x) $ predP i; - count :: (Copeanoid i, Alternative f, Alternative g, Traversable g) => i -> f x -> f (g x); + count :: (Copeanoid i, Applicative f, Alternative g, Traversable g) => i -> f x -> f (g x); count i x = sequenceA (replicate i x); choice :: (Foldable t, Alternative f) => t (f x) -> f x; @@ -641,9 +646,6 @@ modifyBit :: Bits a => Bool -> a -> Int -> a; modifyBit x = bool clearBit setBit x; - - reSigned :: (Integral t, Bits t, Integral u, Bits u) => t -> u; - reSigned x = modifyBit (testBit x n) (transInt $ clearBit x n) n where { n = pred (bitSize x) }; getBits :: (Bits t, Integral t, Integral u) => Int -> Int -> t -> u; getBits h l n = transInt $ shiftR n (h + 1 - l) .&. ((2 ^ l) - 1);
prelude-generalize.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented. -Version: 0.3.1 +Version: 0.4 -- A short (one-line) description of the package. Synopsis: Another kind of alternate Prelude file