From 765be70756f2590c0e8f7698037103b2500cbdea Mon Sep 17 00:00:00 2001 From: David Knothe Date: Fri, 27 Aug 2021 14:15:18 +0200 Subject: [PATCH] Declare `die` for GHC 7.8 and below --- packages/cli/src/Happy/CLI/Dying.hs | 9 ++++++++- packages/frontend/src/Happy/Frontend.hs | 5 ++++- packages/tabular/src/Happy/Tabular.hs | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/Happy/CLI/Dying.hs b/packages/cli/src/Happy/CLI/Dying.hs index d5c2196e..bbab0998 100644 --- a/packages/cli/src/Happy/CLI/Dying.hs +++ b/packages/cli/src/Happy/CLI/Dying.hs @@ -2,10 +2,17 @@ module Happy.CLI.Dying (die, dieUsage, dieHappy, bye, byeUsage, getProgramName, import System.Console.GetOpt import System.Environment -import System.Exit (die, exitWith, ExitCode(..)) +import System.Exit (exitWith, ExitCode(..)) import Control.Monad (liftM) import Data.List (isSuffixOf) +#if MIN_VERSION_base(4,8,0) +import System.Exit (die) +#else +die :: String -> IO a +die s = hPutStr stderr s >> exitWith (ExitFailure 1) +#endif + dieHappy :: String -> IO a dieHappy s = getProgramName >>= \prog -> die (prog ++ ": " ++ s) diff --git a/packages/frontend/src/Happy/Frontend.hs b/packages/frontend/src/Happy/Frontend.hs index 00814a54..7f2a0f23 100644 --- a/packages/frontend/src/Happy/Frontend.hs +++ b/packages/frontend/src/Happy/Frontend.hs @@ -55,7 +55,10 @@ writePrettyFile location abssyn = do possDelitify :: String -> String -> IO (String, String) possDelitify ('y':'l':'.':nm) fl = return (deLitify fl, reverse nm) possDelitify ('y':'.':nm) fl = return (fl, reverse nm) -possDelitify f _ = die ("`" ++ reverse f ++ "' does not end in `.y' or `.ly'\n") where +possDelitify f _ = die ("`" ++ reverse f ++ "' does not end in `.y' or `.ly'\n") +#if !MIN_VERSION_base(4,8,0) + where die s = hPutStr stderr s >> exitWith (ExitFailure 1) +#endif deLitify :: String -> String deLitify = deLit where diff --git a/packages/tabular/src/Happy/Tabular.hs b/packages/tabular/src/Happy/Tabular.hs index 1ef50478..92d2a5ee 100644 --- a/packages/tabular/src/Happy/Tabular.hs +++ b/packages/tabular/src/Happy/Tabular.hs @@ -106,6 +106,9 @@ reportConflicts g sr rr = case expect g of if rr /= 0 then hPutStrLn stderr ("reduce/reduce conflicts: " ++ show rr) else return () +#if !MIN_VERSION_base(4,8,0) + where die s = hPutStr stderr s >> exitWith (ExitFailure 1) +#endif type ItemSetWithGotos = (Set Lr0Item, [(Name,Int)]) writeInfoFile :: [ItemSetWithGotos] -> Grammar -> ActionTable -> GotoTable -> Array Int (Int,Int) -> String -> Maybe String -> [Int] -> [String] -> IO ()