X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Futils%2FUtil.lhs;fp=compiler%2Futils%2FUtil.lhs;h=dc4f32ec5e7d7f4dffec59df200cd8fd6db7cf3c;hp=0e46889ec549fa3496f6fdb6c67a0eafc098e662;hb=f3a77b2f46ebc27716f45ae426a3b33b853d52f5;hpb=70f79a6c3c40ca95efc1e2371f663c68c3bb5f08 diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index 0e46889..dc4f32e 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -66,6 +66,9 @@ module Util ( -- * Floating point readRational, + -- * read helpers + maybeReadFuzzy, + -- * IO-ish utilities createDirectoryHierarchy, doesDirNameExist, @@ -966,6 +969,17 @@ readRational top_s ----------------------------------------------------------------------------- +-- read helpers + +maybeReadFuzzy :: Read a => String -> Maybe a +maybeReadFuzzy str = case reads str of + [(x, s)] + | all isSpace s -> + Just x + _ -> + Nothing + +----------------------------------------------------------------------------- -- Create a hierarchy of directories createDirectoryHierarchy :: FilePath -> IO ()