In this code:
import System.Posix.Files import Control.Exception safeStat :: FilePath -> IO (Maybe FileStatus) safeStat path = handle (\_ -> return Nothing) (getFileStatus path >>= (return . Just))
I get this error (in ghci):
Ambiguous type variable `e0' in the constraint: (Exception e0) arising from a use of `handle' ...
I can get rid of the error by encoding something like:
nothing :: IOException -> Maybe a nothing _ = Nothing safeStat :: FilePath -> IO (Maybe FileStatus) safeStat path = handle (return . nothing) (getFileStatus path >>= (return . Just))
What's happening??? I would like hander to handle any exception.
source share