packages feed

safe 0.3 → 0.3.1

raw patch · 2 files changed

+43/−15 lines, 2 files

Files

Safe.hs view
@@ -47,10 +47,12 @@     at, atDef, atMay, atNote,     readDef, readMay, readNote,     lookupJust, lookupJustDef, lookupJustNote,+    findJust, findJustDef, findJustNote,     abort     ) where  +import Data.List import Data.Maybe  @@ -239,6 +241,21 @@ lookupJustNote msg key lst = case lookup key lst of                                  Nothing -> error $ "Safe.lookupJust: element not found, " ++ msg                                  Just x -> x++++-- |+-- > findJust op = fromJust . find op+findJust :: (a -> Bool) -> [a] -> a+findJust op = fromJustNote "findJust, item not found" . find op++findJustDef :: a -> (a -> Bool) -> [a] -> a+findJustDef def op lst = fromMaybe def (find op lst)++findJustNote :: String -> (a -> Bool) -> [a] -> a+findJustNote msg op lst = case find op lst of+                               Nothing -> error $ "Safe.findJust: element not found, " ++ msg+                               Just x -> x   
safe.cabal view
@@ -1,21 +1,32 @@-Name:           safe-Build-Type:     Simple-Version:        0.3-License:        BSD3-License-File:   LICENSE-Copyright:      2007-2010, Neil Mitchell-Maintainer:     ndmitchell@gmail.com-Author:         Neil Mitchell-Homepage:       http://community.haskell.org/~ndm/safe/-Build-Depends:  base < 5-Category:       Unclassified-Synopsis:       Library for safe (pattern match free) functions-Description:+cabal-version:  >= 1.6+build-type:     Simple+name:           safe+version:        0.3.1+license:        BSD3+license-file:   LICENSE+category:       Unclassified+author:         Neil Mitchell <ndmitchell@gmail.com>+maintainer:     Neil Mitchell <ndmitchell@gmail.com>+copyright:      Neil Mitchell 2007-2011+homepage:       http://community.haskell.org/~ndm/safe/+synopsis:       Library for safe (pattern match free) functions+description:     Partial functions from the base library, such as @head@ and @!!@, modified     to return more descriptive error messages, programmer defined error messages,     @Maybe@ wrapped results and default values.          These functions can be used to reduce the number of unsafe pattern matches in     your code.-Exposed-modules:-    Safe+++source-repository head+    type:     darcs+    location: http://community.haskell.org/~ndm/darcs/safe/+++library+    build-depends:+        base < 5++    exposed-modules:+        Safe