packages feed

set-extra (empty) → 1.2

raw patch · 10 files changed

+295/−0 lines, 10 filesdep +basedep +containersdep +mtlsetup-changed

Dependencies added: base, containers, mtl, syb

Files

+ COPYING view
@@ -0,0 +1,34 @@+This package was cabalized by David Fox+<dsf@seereason.com> on August 24, 2011.++Copyright (c) 2011, David Fox++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are+met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * The names of contributors may not be used to endorse or promote+      products derived from this software without specific prior+      written permission. ++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Data/Set/Extra.hs view
@@ -0,0 +1,101 @@+module Data.Set.Extra+    ( module Data.Set+    , catMaybes +    , flatten+    , concatMap+    , mapM+    , filterM+    , concatMapM+    , any+    , all+    , distrib+    , or+    , and+    , ss+    , ssMapM+    , toSS+    , fromSS+    , cartesianProduct+    -- , anyM+    , groupBy+    , partitionM+    , gFind+    ) where++import qualified Control.Monad as List (mapM, filterM, foldM)+import Control.Monad.State ()+import qualified Data.Map as Map+import Data.Set+import Data.Set.ExtraG+import qualified Data.List as List+--import qualified Data.Maybe+import Prelude hiding (mapM, all, any, map, filter, null, concatMap, and, or)+--import qualified Prelude++mapM :: (Monad m, Ord b) => (a -> m b) -> Set a -> m (Set b)+mapM f s = List.mapM f (toList s) >>= return . fromList++filterM :: (Ord a, Monad m) => (a -> m Bool) -> Set a -> m (Set a)+filterM p s = List.filterM p (toList s) >>= return . fromList++catMaybes :: Ord a => Set (Maybe a) -> Set a+catMaybes sm = fold (\ mx s -> maybe s (`insert` s) mx) empty sm++flatten :: Ord a => Set (Set a) -> Set a+flatten ss' = fold union empty ss'+--flatten = unions . toList++concatMap :: (Ord a, Ord b) => (a -> Set b) -> Set a -> Set b+concatMap f s = flatten (Data.Set.map f s)++concatMapM :: (Monad m, Ord a, Ord b) => (a -> m (Set b)) -> Set a -> m (Set b)+concatMapM f s = mapM f s >>= return . flatten++any :: Ord a => (a -> Bool) -> Set a -> Bool+any f s = not . null . filter id . map f $ s++{-+anyM :: Monad m => (a -> m (Maybe Bool)) -> Set a -> m (Maybe Bool)+anyM p s =+    List.mapM p (toList s) >>= return . Data.Maybe.catMaybes >>= return . chk+    where chk [] = Nothing+          chk ys = Just (Prelude.or ys)+-}++all :: Ord a => (a -> Bool) -> Set a -> Bool+all f s = not . null . filter not . map f $ s++or :: Set Bool -> Bool+or = any id++and :: Set Bool -> Bool+and = all id++-- |Create a singleton set containing a singleton set of a.+ss :: Ord a => a -> Set (Set a)+ss = singleton . singleton++-- |Turn a list of lists into a set of sets.+toSS :: Ord a => [[a]] -> Set (Set a)+toSS = fromList . List.map fromList++fromSS :: Ord a => Set (Set a) -> [[a]]+fromSS = List.map toList . toList++ssMapM :: (Monad m, Ord a, Ord b) => (a -> m b) -> Set (Set a) -> m (Set (Set b))+ssMapM f s = List.mapM (List.mapM f) (fromSS s) >>= return . toSS++-- | distrib {a, b, c} {d, e, f} -> {a+d, a+e, a+f, b+d, b+e, b+f, c+d, c+e, c+f}+distrib :: Ord a => Set (Set a) -> Set (Set a) -> Set (Set a)+distrib lss rss = flatten $ map (\ rs -> (map (\ ls -> union rs ls) lss)) rss++cartesianProduct :: (Ord a, Ord b) => Set a -> Set b -> Set (a, b)+cartesianProduct xs ys = flatten $ Data.Set.map (\ x -> Data.Set.map (\ y -> (x, y)) ys) xs++groupBy :: (Ord a, Ord b) => (a -> b) -> Set a -> Map.Map b (Set a)+groupBy f xs = fold (\ x m -> Map.insertWith union (f x) (singleton x) m) Map.empty xs++partitionM :: (Monad m, Ord a) => (a -> m Bool) -> Set a -> m (Set a, Set a)+partitionM p xs =+    List.foldM f (empty, empty) (toList xs)+    where f (ts, fs) x = p x >>= \ flag -> return $ if flag then (insert x ts, fs) else (ts, insert x fs)
+ Data/Set/ExtraG.hs view
@@ -0,0 +1,18 @@+{-# LANGUAGE RankNTypes, ScopedTypeVariables #-}+module Data.Set.ExtraG +    ( gFind+    ) where++import Data.Generics hiding (GT)+import Control.Monad.Reader+import Data.Set (Set, fromList)++gFind :: forall a b. (Data a, Typeable b, Ord b) => a -> Set b+gFind x = fromList (gFind' x :: [b])++-- | @gFind a@ will extract any elements of type @b@ from+-- @a@'s structure in accordance with the MonadPlus+-- instance, e.g. Maybe Foo will return the first Foo+-- found while [Foo] will return the list of Foos found.+gFind' :: (MonadPlus m, Data a, Typeable b) => a -> m b+gFind' = msum . map return . listify (const True)
+ Setup.hs view
@@ -0,0 +1,5 @@+#!/usr/bin/runhaskell++import Distribution.Simple++main = defaultMainWithHooks simpleUserHooks
+ debian/changelog view
@@ -0,0 +1,18 @@+haskell-set-extra (1.2) unstable; urgency=low++  * Fix gFind.++ -- David Fox <dsf@seereason.com>  Wed, 24 Aug 2011 22:29:50 -0700++haskell-set-extra (1.1) unstable; urgency=low++  * Add gFind for sets.++ -- David Fox <dsf@seereason.com>  Wed, 24 Aug 2011 13:16:35 -0700++haskell-set-extra (1.0-1~hackage1) unstable; urgency=low++  * Debianization generated by cabal-debian++ -- David Fox <dsf@seereason.com>  Wed, 24 Aug 2011 10:26:35 -0700+
+ debian/compat view
@@ -0,0 +1,1 @@+7
+ debian/control view
@@ -0,0 +1,62 @@+Source: haskell-set-extra+Priority: extra+Section: haskell+Maintainer: David Fox <dsf@seereason.com>+Build-Depends: debhelper (>= 7.0),+               haskell-devscripts (>= 0.8),+               cdbs,+               ghc,+               ghc-prof,+               libghc-mtl-prof,+               libghc-syb-prof+Build-Depends-Indep: ghc-doc,+                     libghc-mtl-doc,+                     libghc-syb-doc+Standards-Version: 3.9.1+Homepage: http://src.seereason.com/set-extra++Package: libghc-set-extra-dev+Architecture: any+Depends: ${shlibs:Depends},+         ${haskell:Depends},+         ${misc:Depends}+Recommends: ${haskell:Recommends}+Suggests: ${haskell:Suggests}+Provides: ${haskell:Provides}+Description: Functions that could be added to Data.Set.+ Functions that could be added to Data.Set.+ .+  Author: David Fox+  Upstream-Maintainer: David Fox <dsf@seereason.com>+ .+ This package contains the normal library files.++Package: libghc-set-extra-prof+Architecture: any+Depends: ${haskell:Depends},+         ${misc:Depends}+Recommends: ${haskell:Recommends}+Suggests: ${haskell:Suggests}+Provides: ${haskell:Provides}+Description: Functions that could be added to Data.Set.+ Functions that could be added to Data.Set.+ .+  Author: David Fox+  Upstream-Maintainer: David Fox <dsf@seereason.com>+ .+ This package contains the libraries compiled with profiling enabled.++Package: libghc-set-extra-doc+Architecture: all+Section: doc+Depends: ${haskell:Depends},+         ${misc:Depends}+Recommends: ${haskell:Recommends}+Suggests: ${haskell:Suggests}+Description: Functions that could be added to Data.Set.+ Functions that could be added to Data.Set.+ .+  Author: David Fox+  Upstream-Maintainer: David Fox <dsf@seereason.com>+ .+ This package contains the documentation files.
+ debian/copyright view
@@ -0,0 +1,34 @@+This package was cabalized by David Fox+<dsf@seereason.com> on August 24, 2011.++Copyright (c) 2011, David Fox++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are+met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * The names of contributors may not be used to endorse or promote+      products derived from this software without specific prior+      written permission. ++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ debian/rules view
@@ -0,0 +1,8 @@+#!/usr/bin/make -f+include /usr/share/cdbs/1/rules/debhelper.mk+include /usr/share/cdbs/1/class/hlibrary.mk+++# How to install an extra file into the documentation package+#binary-fixup/libghc-set-extra-doc::+#	echo "Some informative text" > debian/libghc-set-extra-doc/usr/share/doc/libghc-set-extra-doc/AnExtraDocFile
+ set-extra.cabal view
@@ -0,0 +1,14 @@+Name:           set-extra+Version:        1.2+License:        BSD3+License-File:	COPYING+Author:         David Fox+Category:       Data+Description:    Functions that could be added to Data.Set.+Synopsis:       Functions that could be added to Data.Set.+Maintainer:     David Fox <dsf@seereason.com>+Homepage:       http://src.seereason.com/set-extra+ghc-options:	-O2 -Wall+Exposed-modules: Data.Set.Extra, Data.Set.ExtraG+Build-Depends: base < 5, containers, mtl, syb+Build-Type: Simple