1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
--- 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]
|