prelude-generalize 0.1 → 0.1.1
raw patch · 2 files changed
+29/−2 lines, 2 files
Files
- Prelude/Generalize.hs +28/−1
- prelude-generalize.cabal +1/−1
Prelude/Generalize.hs view
@@ -14,7 +14,8 @@ low8bits, modifyBit, reSigned, getBits, transPeano, Part1M, Part1(..), Part2M, Part2(..), Part3M, Part3(..), Part4M, Part4(..), Part5M, Part5(..), Part6M, Part6(..), QuestionMarkOp(..), selectItems, selectBits, hGetByte, - hPutByte, module System.IO + hPutByte, module System.IO, (>>=||), (>>=|||), (>>=|\/), (>>=\/), azero, + aplus, unnull ) where { import Prelude hiding (head, tail, (!!), foldr, foldl, length, filter, mapM_, @@ -482,6 +483,11 @@ {-# RULES "L.null" null = L.null #-}; {-# RULES "M.null" null = M.isNothing #-}; + unnull :: Foldable t => t x -> Bool; + unnull = foldr (\_ _ -> True) False; +{-# RULES "L.unnull" unnull = not . L.null #-}; +{-# RULES "M.unnull" null = M.isJust #-}; + concat :: (MonadPlus m, Foldable f) => m (f x) -> m x; concat = (>>= foldr (mplus . return) mzero); {-# RULES "L.concat" concat = L.concat #-}; @@ -554,4 +560,25 @@ hGetByte :: Handle -> IO Word8; hGetByte h = alloca (\y -> IO.hGetBuf h y 1 >> peek y); + (>>=||) :: Monad m => m (a, b) -> (a -> b -> m z) -> m z; + m >>=|| f = m >>= \(a, b) -> f a b; + infixl 1 >>=||; + + (>>=|||) :: Monad m => m (a, b, c) -> (a -> b -> c -> m z) -> m z; + m >>=||| f = m >>= \(a, b, c) -> f a b c; + infixl 1 >>=|||; + + (>>=|\/) :: Monad m => m (a, b, c, d) -> (a -> b -> c -> d -> m z) -> m z; + m >>=|\/ f = m >>= \(a, b, c, d) -> f a b c d; + infixl 1 >>=|\/; + + (>>=\/) :: Monad m => m (a, b, c, d, e) -> (a -> b -> c -> d -> e -> m z) -> m z; + m >>=\/ f = m >>= \(a, b, c, d, e) -> f a b c d e; + infixl 1 >>=\/; + + azero :: (Applicative f, Monoid x) => f x; + azero = pure mempty; + + aplus :: (Applicative f, Monoid x) => f x -> f x -> f x; + aplus = liftA2 mappend; }
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.1 +Version: 0.1.1 -- A short (one-line) description of the package. Synopsis: Another kind of alternate Prelude file