packages feed

ghc-core 0.4.3 → 0.5

raw patch · 4 files changed

+26/−15 lines, 4 filesdep +colorize-haskelldep −hscolourdep ~base

Dependencies added: colorize-haskell

Dependencies removed: hscolour

Dependency ranges changed: base

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2008 Don Stewart+Copyright (c) 2008-9 Don Stewart  All rights reserved. 
+ README view
@@ -0,0 +1,2 @@+A convenient command line wrapper over GHC to display GHC's optimised+Core and assembly output in a human readable manner.
ghc-core.cabal view
@@ -1,5 +1,5 @@ name:           ghc-core-version:        0.4.3+version:        0.5 license:        BSD3 license-file:   LICENSE author:         Don Stewart@@ -26,10 +26,10 @@ -- Technically, hscolour-1.10.* will work too if we replace the -- 'NoLit' constructor with 'False' in the call to 'hscolour'. executable ghc-core-    build-depends:  base,+    build-depends:  base < 10,                     process >=1.0.1,                     pcre-light,-                    hscolour >=1.11,+                    colorize-haskell,                     directory,                     filepath     main-is:        ghc-core.hs
ghc-core.hs view
@@ -39,10 +39,15 @@  import Text.Regex.PCRE.Light.Char8 +-- BSD-licensed Haskell syntax highlighting, based on Programmatica+import Language.Haskell.Colorize++{- import Language.Haskell.HsColour import Language.Haskell.HsColour.Colourise -- 'Literate' is hscolour-1.11 only. 'Bool' was used in hscolour-1.10 import Language.Haskell.HsColour.Options (Literate(..))+-}  ------------------------------------------------------------------------ --@@ -51,7 +56,7 @@  data Options = Options   { optHelp   :: Bool-  , optFormat :: Output+--  , optFormat :: Output   , optGhcExe :: String   , optAsm    :: Bool   } deriving (Eq, Show)@@ -59,20 +64,20 @@ defaultOptions :: Options defaultOptions = Options   { optHelp    = False-  , optFormat  = TTY+--  , optFormat  = TTY   , optGhcExe  = "ghc"   , optAsm     = True   } -formats :: [(String, Output)]-formats = [("css", CSS), ("html", HTML), ("tty", TTY)]+-- formats :: [(String, Output)]+-- formats = [("css", CSS), ("html", HTML), ("tty", TTY)]  options :: [OptDescr (Options -> Options)] options =-    [   Option ['f'] ["format"] -            (ReqArg (\x opts -> opts { optFormat = fromString x }) "FORMAT")-            ("Output format " ++ formats' ++ ".")-        ,Option ['h'] ["help"]+    [ --  Option ['f'] ["format"]+      --      (ReqArg (\x opts -> opts { optFormat = fromString x }) "FORMAT")+      --      ("Output format " ++ formats' ++ ".")+         Option ['h'] ["help"]             (NoArg (\opts -> opts { optHelp = True }))             "Print this help message."         ,Option [] ["with-ghc"]@@ -83,11 +88,12 @@             "Don't output generated assembly code."     ]     where-        fromString  f = fromMaybe (formatError f) (lookup f formats)+{-      fromString  f = fromMaybe (formatError f) (lookup f formats)         formatError f = error $                             "invalid format `" ++ f ++ "'"                             ++ ", must be one of " ++ formats' ++ "."         formats' = "(" ++ concat (intersperse ", " (map fst formats)) ++ ")"+-}  parseOptions :: [String] -> IO (Options, [String]) parseOptions argv = @@ -110,7 +116,7 @@     (opts, args) <- getArgs >>= parseOptions      -- Read colors from .hscolour-    colourPrefs <- readColourPrefs+--    colourPrefs <- readColourPrefs      mv <- getEnvMaybe "PAGER"     let less = case mv of Just s -> case s of "less" -> "less -f" ; _ -> s@@ -131,13 +137,16 @@                                        then do asm <- readFile (init s)                                                return ((strs' ++ asm), Just $ takeDirectory s)                                        else return (strs', Just $ takeDirectory s)-    ++{-     -- If we replace the 'NoLit' constructor with 'False' (and     -- remove the include for the Literate type), then this will     -- work with older hscolour-1.10.* versions.     let nice = hscolour                 (optFormat opts)                 colourPrefs False True NoLit [] strs+-}+    let nice = render ansiLight strs []      bracket         (openTempFile "/tmp" "ghc-core-XXXX.hcr")