packages feed

yjtools 0.2 → 0.4

raw patch · 4 files changed

+36/−11 lines, 4 files

Files

Control/Monad/Utils.hs view
@@ -4,19 +4,12 @@ , unlessM , doWhile_ , doWhile+, for_+, for ) where  import Control.Monad         (when, unless) -doWhile :: Monad m => a -> (a -> m (a, Bool)) -> m a-doWhile i act = do (r, p) <- act i-                   if p then doWhile r act-		        else return r--doWhile_ :: Monad m => m Bool -> m ()-doWhile_ act = do p <- act-                  when p $ doWhile_ act- ifM :: Monad m => m Bool -> m a -> m a -> m a ifM p t e = do b <- p                if b then t else e@@ -24,3 +17,22 @@ whenM, unlessM :: Monad m => m Bool -> m () -> m () whenM p t   = p >>= flip when t unlessM p e = p >>= flip unless e++doWhile_ :: Monad m => m Bool -> m ()+doWhile_ act = do p <- act+                  when p $ doWhile_ act++doWhile :: Monad m => a -> (a -> m (a, Bool)) -> m a+doWhile i act = do (r, p) <- act i+                   if p then doWhile r act+		        else return r++for_ :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m b) -> m ()+for_ i test next act+  | test i    = act i >> for_ (next i) test next act+  | otherwise = return ()++for :: Monad m => a -> (a -> Bool) -> (a -> a) -> b -> (a -> b -> m b) -> m b+for i test next j act+  | test i    = act i j >>= flip (for (next i) test next) act+  | otherwise = return j
Data/Function/Tools.hs view
@@ -1,6 +1,14 @@ module Data.Function.Tools (   const2+, applyWhen+, apply2way ) where  const2 :: a -> b -> c -> a const2 = const . const++applyWhen :: Bool -> (a -> a) -> a -> a+applyWhen b f = if b then f else id++apply2way :: (a -> b -> c) -> (d -> a) -> (d -> b) -> d -> c+apply2way fgen f1 f2 x = fgen (f1 x) (f2 x)
Data/List/Tools.hs view
@@ -1,7 +1,12 @@ module Data.List.Tools (   mulLists+, defaultElem ) where  mulLists :: [[a]] -> [[a]] mulLists []       = [[]] mulLists (xs:xss) = [ x:xs_ | x <- xs, xs_ <- mulLists xss ]++defaultElem :: a -> [a] -> [a]+defaultElem dflt []  = [ dflt ]+defaultElem _    lst = lst
yjtools.cabal view
@@ -1,5 +1,5 @@ Name:		yjtools-Version:	0.2+Version:	0.4 Cabal-Version:	>= 1.2 Build-Type:	Simple License:	GPL@@ -8,7 +8,7 @@ Maintainer:	Yoshikuni Jujo <PAF01143@nifty.ne.jp> Stability:	experimental Homepage:	http://homepage3.nifty.com/salamander/second/projects/yjtools/index.xhtml-Package-Url:	http://homepage3.nifty.com/salamander/second/portage/distfiles/yj-gentoo-haskell-tools-0.0.tar.gz+Package-Url:	http://homepage3.nifty.com/salamander/second/portage/distfiles/yjtools-0.2.tar.gz Synopsis:	some tools for Monad Description:	ifM, whenM, unlessM, doWhile, doWhile_ and so on. Category:	Unclassified