[auto
ekmett@gmail.com**20090329184106] {
hunk ./doc/html/monoids/Data-Group-Combinators.html 78
+>
prop_replicate_right_distributive :: (Eq g, Group g, Arbitrary g, Integral n) => g -> n -> n -> Bool | SourceQuickCheck Properties
+ | | prop_replicate_right_distributive :: (Eq m, Monoid m, Arbitrary m, Integral n) => m -> n -> n -> Bool | | QuickCheck Properties
+ | | | prop_replicate_right_distributive | 1 (Function) | Data.Group.Combinators | 2 (Function) | Data.Monoid.Combinators | , replicate
- ) where
-
-import Prelude hiding (replicate)
-import Data.Group
+
+ , replicate
+
+ , prop_replicate_right_distributive
+ ) where
hunk ./doc/html/monoids/src/Data-Group-Combinators.html 34
-
-
-
-replicate :: (Group m, Integral n) => m -> n -> m
-replicate x0 y0
- | y0 < 0 = f (gnegate x0) (negate y0)
- | y0 == 0 = mempty
- | otherwise = f x0 y0
- where
- f x y
- | even y = f (x `mappend` x) (y `quot` 2)
- | y == 1 = x
- | otherwise = g (x `mappend` x) ((y 1) `quot` 2) x
- g x y z
- | even y = g (x `mappend` x) (y `quot` 2) z
- | y == 1 = x `mappend` z
- | otherwise = g (x `mappend` x) ((y 1) `quot` 2) (x `mappend` z)
-
+import Prelude hiding (replicate)
+import Data.Group
+import Test.QuickCheck
+
+
+
+
+replicate :: (Group m, Integral n) => m -> n -> m
+replicate x0 y0
+ | y0 < 0 = f (gnegate x0) (negate y0)
+ | y0 == 0 = mempty
+ | otherwise = f x0 y0
+ where
+ f x y
+ | even y = f (x `mappend` x) (y `quot` 2)
+ | y == 1 = x
+ | otherwise = g (x `mappend` x) ((y 1) `quot` 2) x
+ g x y z
+ | even y = g (x `mappend` x) (y `quot` 2) z
+ | y == 1 = x `mappend` z
+ | otherwise = g (x `mappend` x) ((y 1) `quot` 2) (x `mappend` z)
+
+prop_replicate_right_distributive :: (Eq g, Group g, Arbitrary g, Integral n) => g -> n -> n -> Bool
+prop_replicate_right_distributive g x y
+ = replicate g (x + y) == replicate g x `mappend` replicate g y
hunk ./doc/html/monoids/src/Data-Monoid-Combinators.html 55
- ) where
-
-import Prelude hiding (mapM_, any, elem, filter, concatMap, and, or, all, sum, product, notElem, replicate, cycle, repeat)
-import Control.Applicative
-import Data.Monoid.Generator
-import Data.Monoid.Applicative
-import Data.Monoid.Self
-import Data.Monoid.Monad
-
-
-traverse_ :: (Generator c, Applicative f) => (Elem c -> f b) -> c -> f ()
-traverse_ f = getTraversal . mapReduce f
-
-
-for_ :: (Generator c, Applicative f) => c -> (Elem c -> f b) -> f ()
-for_ = flip traverse_
-
-
-mapM_ :: (Generator c, Monad m) => (Elem c -> m b) -> c -> m ()
-mapM_ f = getAction . mapReduce f
-
-
-forM_ :: (Generator c, Monad m) => c -> (Elem c -> m b) -> m ()
-forM_ = flip mapM_
-
-
-foldMap :: (Monoid m, Generator c) => (Elem c -> m) -> c -> m
-foldMap f = getSelf . mapReduce f
-
-
-fold :: (Monoid m, Generator c, Elem c ~ m) => c -> m
-fold = getSelf . reduce
-
-
-concatMap :: Generator c => (Elem c -> [b]) -> c -> [b]
-concatMap = foldMap
-
-
-and :: (Generator c, Elem c ~ Bool) => c -> Bool
-and = getAll . reduce
-
-
-or :: (Generator c, Elem c ~ Bool) => c -> Bool
-or = getAny . reduce
-
-
-any :: Generator c => (Elem c -> Bool) -> c -> Bool
-any f = getAny . mapReduce f
-
-
-all :: Generator c => (Elem c -> Bool) -> c -> Bool
-all f = getAll . mapReduce f
-
-
-sum :: (Generator c, Num (Elem c)) => c -> Elem c
-sum = getSum . reduce
-
-
-product :: (Generator c, Num (Elem c)) => c -> Elem c
-product = getProduct . reduce
-
-
-elem :: (Generator c, Eq (Elem c)) => Elem c -> c -> Bool
-elem = any . (==)
-
-
-notElem :: (Generator c, Eq (Elem c)) => Elem c -> c -> Bool
-notElem x = not . elem x
-
-
-filter :: (Generator c, Elem c `Reducer` m) => (Elem c -> Bool) -> c -> m
-filter p = foldMap f where
- f x | p x = unit x
- | otherwise = mempty
-
-
-find :: Generator c => (Elem c -> Bool) -> c -> Maybe (Elem c)
-find p = getFirst . filter p
-
-
-
-replicate :: (Monoid m, Integral n) => m -> n -> m
-replicate x0 y0
- | y0 < 0 = mempty
- | y0 == 0 = mempty
- | otherwise = f x0 y0
- where
- f x y
- | even y = f (x `mappend` x) (y `quot` 2)
- | y == 1 = x
- | otherwise = g (x `mappend` x) ((y 1) `quot` 2) x
- g x y z
- | even y = g (x `mappend` x) (y `quot` 2) z
- | y == 1 = x `mappend` z
- | otherwise = g (x `mappend` x) ((y 1) `quot` 2) (x `mappend` z)
-
-
-cycle :: Monoid m => m -> m
-cycle xs = xs' where xs' = xs `mappend` xs'
-
-
-repeat :: (e `Reducer` m) => e -> m
-repeat x = xs where xs = cons x xs
+
+ , prop_replicate_right_distributive
+ ) where
+
+import Prelude hiding (mapM_, any, elem, filter, concatMap, and, or, all, sum, product, notElem, replicate, cycle, repeat)
+import Control.Applicative
+import Data.Monoid.Generator
+import Data.Monoid.Applicative
+import Data.Monoid.Self
+import Data.Monoid.Monad
+import Test.QuickCheck
+
+
+traverse_ :: (Generator c, Applicative f) => (Elem c -> f b) -> c -> f ()
+traverse_ f = getTraversal . mapReduce f
+
+
+for_ :: (Generator c, Applicative f) => c -> (Elem c -> f b) -> f ()
+for_ = flip traverse_
+
+
+mapM_ :: (Generator c, Monad m) => (Elem c -> m b) -> c -> m ()
+mapM_ f = getAction . mapReduce f
+
+
+forM_ :: (Generator c, Monad m) => c -> (Elem c -> m b) -> m ()
+forM_ = flip mapM_
+
+
+foldMap :: (Monoid m, Generator c) => (Elem c -> m) -> c -> m
+foldMap f = getSelf . mapReduce f
+
+
+fold :: (Monoid m, Generator c, Elem c ~ m) => c -> m
+fold = getSelf . reduce
+
+
+concatMap :: Generator c => (Elem c -> [b]) -> c -> [b]
+concatMap = foldMap
+
+
+and :: (Generator c, Elem c ~ Bool) => c -> Bool
+and = getAll . reduce
+
+
+or :: (Generator c, Elem c ~ Bool) => c -> Bool
+or = getAny . reduce
+
+
+any :: Generator c => (Elem c -> Bool) -> c -> Bool
+any f = getAny . mapReduce f
+
+
+all :: Generator c => (Elem c -> Bool) -> c -> Bool
+all f = getAll . mapReduce f
+
+
+sum :: (Generator c, Num (Elem c)) => c -> Elem c
+sum = getSum . reduce
+
+
+product :: (Generator c, Num (Elem c)) => c -> Elem c
+product = getProduct . reduce
+
+
+elem :: (Generator c, Eq (Elem c)) => Elem c -> c -> Bool
+elem = any . (==)
+
+
+notElem :: (Generator c, Eq (Elem c)) => Elem c -> c -> Bool
+notElem x = not . elem x
+
+
+filter :: (Generator c, Elem c `Reducer` m) => (Elem c -> Bool) -> c -> m
+filter p = foldMap f where
+ f x | p x = unit x
+ | otherwise = mempty
+
+
+find :: Generator c => (Elem c -> Bool) -> c -> Maybe (Elem c)
+find p = getFirst . filter p
+
+
+
+replicate :: (Monoid m, Integral n) => m -> n -> m
+replicate x0 y0
+ | y0 < 0 = mempty
+ | y0 == 0 = mempty
+ | otherwise = f x0 y0
+ where
+ f x y
+ | even y = f (x `mappend` x) (y `quot` 2)
+ | y == 1 = x
+ | otherwise = g (x `mappend` x) ((y 1) `quot` 2) x
+ g x y z
+ | even y = g (x `mappend` x) (y `quot` 2) z
+ | y == 1 = x `mappend` z
+ | otherwise = g (x `mappend` x) ((y 1) `quot` 2) (x `mappend` z)
+
+
+cycle :: Monoid m => m -> m
+cycle xs = xs' where xs' = xs `mappend` xs'
+
+
+repeat :: (e `Reducer` m) => e -> m
+repeat x = xs where xs = cons x xs
+
+prop_replicate_right_distributive :: (Eq m, Monoid m, Arbitrary m, Integral n) => m -> n -> n -> Bool
+prop_replicate_right_distributive m x y
+ = replicate m (x + y) == replicate m x `mappend` replicate m y
}
|