summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UtilityTM.cabal17
-rw-r--r--src/Control/Monad/TM.hs17
2 files changed, 28 insertions, 6 deletions
diff --git a/UtilityTM.cabal b/UtilityTM.cabal
index 6d15e1d..c2a0019 100644
--- a/UtilityTM.cabal
+++ b/UtilityTM.cabal
@@ -1,17 +1,22 @@
Name: UtilityTM
-Version: 0.0.3
+Version: 0.0.4
License: BSD3
License-File: LICENSE
Author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>
Maintainer: Tony Morris
+Copyright: Tony Morris
Synopsis: Utility functions that are missing from the standard library
Category: Development
Description: Utility functions that are missing from the standard library
-Homepage: https://bitbucket.org/dibblego/utility-tm/
-Cabal-version: >= 1.2
+Homepage: https://github.com/tonymorris/utility-tm
+Cabal-version: >= 1.6
Build-Type: Simple
-Flag small_base
+Source-Repository head
+ Type: git
+ Location: git@github.com:tonymorris/utility-tm.git
+
+Flag small_base
Description: Choose the new, split-up base package.
Library
@@ -25,5 +30,5 @@ Library
src
Exposed-Modules:
- Control.Monad.TM
-
+ Control.Monad.TM
+
diff --git a/src/Control/Monad/TM.hs b/src/Control/Monad/TM.hs
index 37c3520..f0ec75b 100644
--- a/src/Control/Monad/TM.hs
+++ b/src/Control/Monad/TM.hs
@@ -5,6 +5,7 @@ module Control.Monad.TM
, (.>>=.)
, anyM
, allM
+, findM
) where
import Control.Applicative
@@ -56,3 +57,19 @@ allM f (a:as) =
if z
then allM f as
else return False
+
+-- | Find an element satisfying a predicate
+findM ::
+ Monad m =>
+ (a -> m Bool)
+ -> [a]
+ -> m (Maybe a)
+findM _ [] =
+ return Nothing
+findM f (x:xs) =
+ do b <- f x
+ if b
+ then
+ return (Just x)
+ else
+ findM f xs