From c643136e32b99a650a6fdea0731ea5af275f6866 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 31 Oct 2011 23:39:55 -0400 Subject: playing with >=> Apparently in haskell if you teach a man to fish, he'll write more pointfree code. --- Utility/Misc.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Utility/Misc.hs') diff --git a/Utility/Misc.hs b/Utility/Misc.hs index bc1834774..b3bf22612 100644 --- a/Utility/Misc.hs +++ b/Utility/Misc.hs @@ -8,15 +8,16 @@ module Utility.Misc where import System.IO +import Control.Monad {- A version of hgetContents that is not lazy. Ensures file is - all read before it gets closed. -} hGetContentsStrict :: Handle -> IO String -hGetContentsStrict h = hGetContents h >>= \s -> length s `seq` return s +hGetContentsStrict = hGetContents >=> \s -> length s `seq` return s {- A version of readFile that is not lazy. -} readFileStrict :: FilePath -> IO String -readFileStrict f = readFile f >>= \s -> length s `seq` return s +readFileStrict = readFile >=> \s -> length s `seq` return s {- Attempts to read a value from a String. -} readMaybe :: (Read a) => String -> Maybe a -- cgit v1.2.3