Int32.TryParse FSharp Implementation in Haskell
I liked the Int32.TryParse function in F # and wanted to make my own in Haskell:
import qualified Control.Exception as CE handler:: CE.ErrorCall -> IO (Bool,Int) handler e = return (False,0) s2Int :: String->Int s2Int s = read s tryParse :: String -> IO (Bool,Int) tryParse s = CE.catch (s2Int s `seq` return (True,read s)) handler
Seven lines to parse Int ?! Is there a shorter way?
source to share