Skip to content

Commit

Permalink
Declare die for GHC 7.8 and below
Browse files Browse the repository at this point in the history
  • Loading branch information
knothed committed Aug 27, 2021
1 parent 9db33f3 commit b6def85
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/cli/src/Happy/CLI/Dying.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ 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
import System.IO
die :: String -> IO a
die s = hPutStr stderr s >> exitWith (ExitFailure 1)
#endif

dieHappy :: String -> IO a
dieHappy s = getProgramName >>= \prog -> die (prog ++ ": " ++ s)

Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/src/Happy/Frontend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions packages/tabular/src/Happy/Tabular.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down

0 comments on commit b6def85

Please sign in to comment.