JPMoresmau / scion-class-browser

Scion part for EclipseFP Class Browser
16 stars 6 forks source link

Exception.catch (ghc-7.6.1) #2

Closed jwaldmann closed 11 years ago

jwaldmann commented 12 years ago

Hi, because of Prelude.catch vanishing, you need something like the following?

diff --git a/src/Scion/Packages.hs b/src/Scion/Packages.hs
index 698666d..eeb20c3 100644
--- a/src/Scion/Packages.hs
+++ b/src/Scion/Packages.hs
@@ -135,7 +135,7 @@ readContents pkgdb =
 #if __GLASGOW_HASKELL__ >= 612
       -- fix the encoding to UTF-8
       hSetEncoding h utf8
-      catch (hGetContents h) (\_ -> do
+      Exc.catch (hGetContents h) (\ (_ :: Exc.SomeException ) -> do
          -- logInfo $ ioeGetErrorString  err
          hClose h
          h' <- openFile file ReadMode
@@ -169,7 +169,7 @@ readContents pkgdb =
     pkgInfoReader ::  FilePath
                       -> IO [InstalledPackageInfo]
waldmann@R630:~/software/haskell/scion-class-browser$ git diff --help
waldmann@R630:~/software/haskell/scion-class-browser$ cat scion-browser.diff 
diff --git a/src/Scion/Packages.hs b/src/Scion/Packages.hs
index 698666d..eeb20c3 100644
--- a/src/Scion/Packages.hs
+++ b/src/Scion/Packages.hs
@@ -135,7 +135,7 @@ readContents pkgdb =
 #if __GLASGOW_HASKELL__ >= 612
       -- fix the encoding to UTF-8
       hSetEncoding h utf8
-      catch (hGetContents h) (\_ -> do
+      Exc.catch (hGetContents h) (\ (_ :: Exc.SomeException ) -> do
          -- logInfo $ ioeGetErrorString  err
          hClose h
          h' <- openFile file ReadMode
@@ -169,7 +169,7 @@ readContents pkgdb =
     pkgInfoReader ::  FilePath
                       -> IO [InstalledPackageInfo]
     pkgInfoReader f = 
-      catch (
+      Exc.catch (
          do
               pkgStr <- readUTF8File f
               let pkgInfo = parseInstalledPackageInfo pkgStr
@@ -178,7 +178,7 @@ readContents pkgdb =
                 ParseFailed _  -> do
                         -- logInfo (show err)
                         return [emptyInstalledPackageInfo]
-        ) (\_->return [emptyInstalledPackageInfo])
+        ) (\ (_ :: Exc.SomeException)->return [emptyInstalledPackageInfo])

   in case pkgdb of
       (PkgDirectory pkgdbDir) -> do
diff --git a/src/Scion/PersistentBrowser/Parser.hs b/src/Scion/PersistentBrowser/Parser.hs
index d08d32c..6e8a9d1 100644
--- a/src/Scion/PersistentBrowser/Parser.hs
+++ b/src/Scion/PersistentBrowser/Parser.hs
@@ -23,6 +23,7 @@ import Text.Parsec.Prim (runP)
 -- import Text.Parsec.ByteString as BS
 import Text.ParserCombinators.Parsec
 import Text.ParserCombinators.Parsec.Pos (newPos)
+import Control.Exception (catch, SomeException)

 -- | Parses the contents of a string containing the 
 --   Hoogle file contents.
@@ -38,7 +39,7 @@ parseHoogleFile fname = (withFile fname ReadMode $
                                       return $ parseHoogleString fname c
                         )
                         `catch`
-                        (\_ -> return $ Left (newErrorMessage (Message "error reading file")
+                        (\(_::SomeException) -> return $ Left (newErrorMessage (Message "error reading file")
                                                               (newPos fname 0 0)))

 -- | Parses a entire directory of Hoogle documentation files
JPMoresmau commented 12 years ago

This has already been done. 3 days ago I committed code in scion-class-browser that compiles under GHC 7.6.1. Unfortunately I cannot test it further than compilation because of a GHC bug on windows. (see http://www.haskell.org/pipermail/haskell-cafe/2012-October/103826.html)

jwaldmann commented 11 years ago

I think this issue can be closed. I confirm that compilation works. When I use eclipsefp, I sometimes get some strange behaviour but that's certainly unrelated.