diff options
author | Joey Hess <joey@kitenet.net> | 2012-01-23 16:57:45 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-01-23 16:57:45 -0400 |
commit | 5e172b43c4dc5d779e4f1af5c1376c9a8ebc60a4 (patch) | |
tree | 312b16e8afcdfa792c87f8e35c7c82507aabda7a /Utility/PartialPrelude.hs | |
parent | bed495db644cc49f45ec2a4f49a572308fc586f7 (diff) |
a few things available elsewhere...
Diffstat (limited to 'Utility/PartialPrelude.hs')
-rw-r--r-- | Utility/PartialPrelude.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Utility/PartialPrelude.hs b/Utility/PartialPrelude.hs index 507fc6252..dbdf4fa5c 100644 --- a/Utility/PartialPrelude.hs +++ b/Utility/PartialPrelude.hs @@ -7,6 +7,8 @@ module Utility.PartialPrelude where +import qualified Data.Maybe + {- read should be avoided, as it throws an error - Instead, use: readMaybe -} read :: Read a => String -> a @@ -36,6 +38,9 @@ last = Prelude.last - - Ignores leading/trailing whitespace, and throws away any trailing - text after the part that can be read. + - + - readMaybe is available in Text.Read in new versions of GHC, + - but that one requires the entire string to be consumed. -} readMaybe :: Read a => String -> Maybe a readMaybe s = case reads s of @@ -44,8 +49,7 @@ readMaybe s = case reads s of {- Like head but Nothing on empty list. -} headMaybe :: [a] -> Maybe a -headMaybe [] = Nothing -headMaybe v = Just $ Prelude.head v +headMaybe = Data.Maybe.listToMaybe {- Like last but Nothing on empty list. -} lastMaybe :: [a] -> Maybe a |