[commit: packages/containers] ghc-head: Add splitRoot examples to comments. (05e31de)

git at git.haskell.org git at git.haskell.org
Thu Jan 16 07:51:04 UTC 2014


Repository : ssh://git@git.haskell.org/containers

On branch  : ghc-head
Link       : http://git.haskell.org/packages/containers.git/commitdiff/05e31de394e91193d3e477f2226119c8f7ed0f64

>---------------------------------------------------------------

commit 05e31de394e91193d3e477f2226119c8f7ed0f64
Author: Ryan Newton <rrnewton at gmail.com>
Date:   Mon Dec 2 23:47:26 2013 -0500

    Add splitRoot examples to comments.


>---------------------------------------------------------------

05e31de394e91193d3e477f2226119c8f7ed0f64
 Data/Map/Base.hs |   14 +++++++++++---
 Data/Set/Base.hs |   14 +++++++++++---
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/Data/Map/Base.hs b/Data/Map/Base.hs
index cafd7d5..5c1c076 100644
--- a/Data/Map/Base.hs
+++ b/Data/Map/Base.hs
@@ -2816,10 +2816,18 @@ foldlStrict f = go
 {-# INLINE foldlStrict #-}
 
 
--- | /O(1)/.  Decompose a map into pieces, based on the structure of the underlying
+-- | /O(1)/.  Decompose a map into pieces based on the structure of the underlying
 -- tree.  No guarantee is made as to the sizes of the pieces; an internal, but
--- deterministic process determines this.  This is most useful for consuming a map in
--- parallel.
+-- deterministic process determines this.  
+--
+-- Examples:
+--     
+-- > splitRoot (fromList (zip [1..6] ['a'..])) ==
+-- >   [fromList [(4,'d')],fromList [(1,'a'),(2,'b'),(3,'c')],fromList [(5,'e'),(6,'f')]]
+--
+-- > splitRoot M.empty == []
+--
+--  This function is useful for consuming a map in parallel.
 splitRoot :: Map k b -> [Map k b]
 splitRoot orig =
   case orig of 
diff --git a/Data/Set/Base.hs b/Data/Set/Base.hs
index 37c0ffa..e3758eb 100644
--- a/Data/Set/Base.hs
+++ b/Data/Set/Base.hs
@@ -1405,10 +1405,18 @@ foldlStrict f = go
     go z (x:xs) = let z' = f z x in z' `seq` go z' xs
 {-# INLINE foldlStrict #-}
 
--- | /O(1)/.  Decompose a set into pieces, based on the structure of the underlying
+-- | /O(1)/.  Decompose a set into pieces based on the structure of the underlying
 -- tree.  No guarantee is made as to the sizes of the pieces; an internal, but
--- deterministic process determines this.  This is most useful for consuming a set in
--- parallel.
+-- deterministic process determines this. 
+--
+-- Examples:
+--     
+-- > splitRoot (fromList [1..6]) ==
+-- >   [fromList [4],fromList [1,2,3],fromList [5,6]]
+--    
+-- > splitRoot M.empty == []
+--
+--  This function is useful for consuming a set in parallel.    
 splitRoot :: Set a -> [Set a]
 splitRoot orig =
   case orig of 



More information about the ghc-commits mailing list