You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-haskell/hscolour/files/hscolour-1.19-ghc-7.5.patch

46 lines
1.7 KiB

--- hscolour-1.19-orig/Language/Haskell/HsColour/Colourise.hs 2011-06-06 03:05:04.000000000 +1000
+++ hscolour-1.19/Language/Haskell/HsColour/Colourise.hs 2012-06-24 10:29:57.990963394 +1000
@@ -1,3 +1,7 @@
+{-# LANGUAGE CPP #-}
+#if (__GLASGOW_HASKELL__>=705)
+{-# LANGUAGE ScopedTypeVariables #-}
+#endif
module Language.Haskell.HsColour.Colourise
( module Language.Haskell.HsColour.ColourHighlight
, ColourPrefs(..)
@@ -9,6 +13,9 @@
import Language.Haskell.HsColour.ColourHighlight
import Language.Haskell.HsColour.Classify (TokenType(..))
+#if (__GLASGOW_HASKELL__>=705)
+import Control.Exception (catch, SomeException)
+#endif
import System.IO (hPutStrLn,stderr)
import System.Environment (getEnv)
import Data.List
@@ -51,6 +58,16 @@
-- | Read colour preferences from .hscolour file in the current directory, or failing that,
-- from \$HOME\/.hscolour, and failing that, returns a default set of prefs.
readColourPrefs :: IO ColourPrefs
+#if (__GLASGOW_HASKELL__>=705)
+readColourPrefs = catch
+ (do val <- readFile ".hscolour"
+ parseColourPrefs ".hscolour" val)
+ (\(_ :: SomeException) -> catch
+ (do home <- getEnv "HOME"
+ val <- readFile (home++"/.hscolour")
+ parseColourPrefs (home++"/.hscolour") val)
+ (\(_ :: SomeException) -> return defaultColourPrefs))
+#else
readColourPrefs = catch
(do val <- readFile ".hscolour"
parseColourPrefs ".hscolour" val)
@@ -59,6 +76,7 @@
val <- readFile (home++"/.hscolour")
parseColourPrefs (home++"/.hscolour") val)
(\_-> return defaultColourPrefs))
+#endif
-- | Convert token classification to colour highlights.
colourise :: ColourPrefs -> TokenType -> [Highlight]