Generate platform version comparision page
[darcs-mirror-hpvt.git] / MaybeRead.hs
1 module MaybeRead where
2
3 import Data.List(find)
4 import Text.Read
5 import Text.ParserCombinators.ReadP
6
7 readMaybe :: Read a => String -> Maybe a
8 readMaybe = readsMaybe reads
9
10 readsMaybe :: ReadS a -> String -> Maybe a
11 readsMaybe func str = maybe Nothing (\x->Just (fst x)) (find (null.snd) (func str))
12
13 readPMaybe :: ReadP a -> String -> Maybe a
14 readPMaybe = readsMaybe.readP_to_S