Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

catchIOError fix #3

Merged
merged 1 commit into from

2 participants

@acfoltzer

Since Prelude.catch no longer exists, switched the uses to
catchIOError with appropriate CPP use to make older versions still
work

@acfoltzer acfoltzer catchIOError
Since `Prelude.catch` no longer exists, switched the uses to
`catchIOError` with appropriate CPP use to make older versions still
work
1fd41ab
@JPMoresmau JPMoresmau merged commit c3f566b into JPMoresmau:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 23, 2012
  1. @acfoltzer

    catchIOError

    acfoltzer authored
    Since `Prelude.catch` no longer exists, switched the uses to
    `catchIOError` with appropriate CPP use to make older versions still
    work
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 4 deletions.
  1. +10 −3 src/Scion/Packages.hs
  2. +9 −1 src/Scion/PersistentBrowser/Parser.hs
View
13 src/Scion/Packages.hs
@@ -31,7 +31,14 @@ import GHC.Paths
import qualified Control.Exception as Exception
--- This was borrowed from the ghc-pkg source:
+#if __GLASGOW_HASKELL__ < 702
+catchIOError :: IO a -> (IOError -> IO a) -> IO a
+catchIOError = catch
+#else
+import System.IO.Error (catchIOError)
+#endif
+
+-- this was borrowed from the ghc-pkg source:
type InstalledPackageInfoString = InstalledPackageInfo_ String
-- | Types of cabal package databases
@@ -135,7 +142,7 @@ readContents pkgdb =
#if __GLASGOW_HASKELL__ >= 612
-- fix the encoding to UTF-8
hSetEncoding h utf8
- catch (hGetContents h) (\_ -> do
+ catchIOError (hGetContents h) (\_ -> do
-- logInfo $ ioeGetErrorString err
hClose h
h' <- openFile file ReadMode
@@ -169,7 +176,7 @@ readContents pkgdb =
pkgInfoReader :: FilePath
-> IO [InstalledPackageInfo]
pkgInfoReader f =
- catch (
+ catchIOError (
do
pkgStr <- readUTF8File f
let pkgInfo = parseInstalledPackageInfo pkgStr
View
10 src/Scion/PersistentBrowser/Parser.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Scion.PersistentBrowser.Parser
@@ -24,6 +25,13 @@ import Text.Parsec.Prim (runP)
import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Pos (newPos)
+#if __GLASGOW_HASKELL__ < 702
+catchIOError :: IO a -> (IOError -> IO a) -> IO a
+catchIOError = catch
+#else
+import System.IO.Error (catchIOError)
+#endif
+
-- | Parses the contents of a string containing the
-- Hoogle file contents.
parseHoogleString :: String -> BS.ByteString -> Either ParseError (Documented Package)
@@ -37,7 +45,7 @@ parseHoogleFile fname = (withFile fname ReadMode $
\hnd -> do c <- BS.hGetContents hnd
return $ parseHoogleString fname c
)
- `catch`
+ `catchIOError`
(\_ -> return $ Left (newErrorMessage (Message "error reading file")
(newPos fname 0 0)))
Something went wrong with that request. Please try again.