Skip to content

Commit 5fe739d

Browse files
committed
Burning the bridges: remove #if for GHC < 8
1 parent b6e9075 commit 5fe739d

File tree

13 files changed

+72
-207
lines changed

13 files changed

+72
-207
lines changed

alex.cabal

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,25 @@ executable alex
122122
ghc-options: -Wall -Wcompat -rtsopts
123123

124124
other-modules:
125-
AbsSyn
126-
CharSet
127-
DFA
128-
DFAMin
129-
DFS
130-
Info
131-
Map
132-
NFA
133-
Output
134-
Paths_alex
135-
Parser
136-
ParseMonad
137-
Scan
138-
Set
139-
Sort
140-
Util
141-
UTF8
142-
Data.Ranged
143-
Data.Ranged.Boundaries
144-
Data.Ranged.RangedSet
145-
Data.Ranged.Ranges
125+
AbsSyn
126+
CharSet
127+
DFA
128+
DFAMin
129+
DFS
130+
Info
131+
NFA
132+
Output
133+
Paths_alex
134+
Parser
135+
ParseMonad
136+
Scan
137+
Sort
138+
Util
139+
UTF8
140+
Data.Ranged
141+
Data.Ranged.Boundaries
142+
Data.Ranged.RangedSet
143+
Data.Ranged.Ranges
146144

147145
test-suite tests
148146
type: exitcode-stdio-1.0

src/AbsSyn.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ module AbsSyn (
2323
StrType(..)
2424
) where
2525

26-
import CharSet ( CharSet, Encoding )
27-
import Map ( Map )
28-
import qualified Map hiding ( Map )
29-
import Data.IntMap (IntMap)
30-
import Sort ( nub' )
31-
import Util ( str, nl )
32-
33-
import Data.Maybe ( fromJust )
26+
import CharSet ( CharSet, Encoding )
27+
import Data.Maybe ( fromJust )
28+
import Data.Map ( Map )
29+
import Data.IntMap ( IntMap )
30+
import Sort ( nub' )
31+
import Util ( str, nl )
32+
import qualified Data.Map as Map
33+
3434

3535
infixl 4 :||
3636
infixl 5 :%%

src/DFA.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
module DFA(scanner2dfa) where
1717

1818
import AbsSyn
19-
import qualified Map
19+
import qualified Data.Map as Map
2020
import qualified Data.IntMap as IntMap
2121
import NFA
2222
import Sort ( msort, nub' )

src/DFAMin.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ module DFAMin (minimizeDFA) where
66

77
import AbsSyn
88

9-
import Data.Map (Map)
10-
import qualified Data.Map as Map
11-
import Data.IntSet (IntSet)
9+
import Data.IntMap ( IntMap )
10+
import Data.IntSet ( IntSet )
11+
import Data.Map ( Map )
12+
import Data.Maybe ( mapMaybe )
13+
14+
import qualified Data.Map as Map
1215
import qualified Data.IntSet as IntSet
13-
import Data.IntMap (IntMap)
1416
import qualified Data.IntMap as IntMap
15-
import qualified Data.List as List
17+
import qualified Data.List as List
1618

1719
-- % Hopcroft's Algorithm for DFA minimization (cut/pasted from Wikipedia):
1820
-- % X refines Y into Y1 and Y2 means

src/DFS.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ Chris Dornan, 23-Jun-94, 2-Jul-96, 29-Aug-96, 29-Sep-97
2323

2424
module DFS where
2525

26-
import Set ( Set )
27-
import qualified Set hiding ( Set )
28-
2926
import Data.Array ( (!), accumArray, listArray )
27+
import Data.Set ( Set )
28+
import qualified Data.Set as Set
3029

3130
-- The result of a depth-first search of a graph is a list of trees,
3231
-- `GForest'. `post_order' provides a post-order traversal of a forest.

src/Data/Ranged/RangedSet.hs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ module Data.Ranged.RangedSet (
2929

3030
import Data.Ranged.Boundaries
3131
import Data.Ranged.Ranges
32-
#if MIN_VERSION_base(4,9,0) && !MIN_VERSION_base(4,11,0)
32+
#if !MIN_VERSION_base(4,11,0)
3333
import Data.Semigroup
34-
#elif !MIN_VERSION_base(4,9,0)
35-
import Data.Monoid
3634
#endif
3735

3836
import qualified Data.List as List
@@ -46,18 +44,12 @@ infixl 5 -<=-, -<-, -?-
4644
newtype DiscreteOrdered v => RSet v = RSet {rSetRanges :: [Range v]}
4745
deriving (Eq, Show, Ord)
4846

49-
#if MIN_VERSION_base(4,9,0)
5047
instance DiscreteOrdered a => Semigroup (RSet a) where
5148
(<>) = rSetUnion
52-
#endif
5349

5450
instance DiscreteOrdered a => Monoid (RSet a) where
55-
#if MIN_VERSION_base(4,9,0)
51+
mempty = rSetEmpty
5652
mappend = (<>)
57-
#else
58-
mappend = rSetUnion
59-
#endif
60-
mempty = rSetEmpty
6153

6254
-- | Determine if the ranges in the list are both in order and non-overlapping.
6355
-- If so then they are suitable input for the unsafeRangedSet function.

src/Info.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
module Info (infoDFA) where
1212

1313
import AbsSyn
14-
import qualified Map
14+
import qualified Data.Map as Map
1515
import qualified Data.IntMap as IntMap
1616
import Util
1717

src/Main.hs

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE CPP #-}
21
{-# LANGUAGE NondecreasingIndentation #-}
32

43
-- -----------------------------------------------------------------------------
@@ -17,56 +16,39 @@ import DFA
1716
import DFAMin
1817
import NFA
1918
import Info
20-
import Map ( Map )
21-
import qualified Map hiding ( Map )
2219
import Output
23-
import ParseMonad ( runP, Warning(..) )
20+
import ParseMonad ( runP, Warning(..) )
2421
import Parser
2522
import Scan
26-
import Util ( hline )
27-
import Paths_alex ( version, getDataDir )
28-
29-
#if __GLASGOW_HASKELL__ < 610
30-
import Control.Exception as Exception ( block, unblock, catch, throw )
31-
#endif
32-
#if __GLASGOW_HASKELL__ >= 610
33-
import Control.Exception ( bracketOnError )
34-
#endif
35-
import Control.Monad ( when, liftM )
36-
import Data.Char ( chr )
37-
import Data.List ( isSuffixOf, nub )
38-
import Data.Version ( showVersion )
23+
import Util ( hline )
24+
import Paths_alex ( version, getDataDir )
25+
26+
import Control.Exception ( bracketOnError )
27+
import Control.Monad ( when, liftM )
28+
import Data.Char ( chr )
29+
import Data.List ( isSuffixOf, nub )
30+
import Data.Map ( Map )
31+
import Data.Version ( showVersion )
3932
import System.Console.GetOpt ( getOpt, usageInfo, ArgOrder(..), OptDescr(..), ArgDescr(..) )
40-
import System.Directory ( removeFile )
41-
import System.Environment ( getProgName, getArgs )
42-
import System.Exit ( ExitCode(..), exitWith )
43-
import System.IO ( stderr, Handle, IOMode(..), openFile, hClose, hPutStr, hPutStrLn )
44-
#if __GLASGOW_HASKELL__ >= 612
45-
import System.IO ( hGetContents, hSetEncoding, utf8 )
46-
#endif
33+
import System.Directory ( removeFile )
34+
import System.Environment ( getProgName, getArgs )
35+
import System.Exit ( ExitCode(..), exitWith )
36+
import System.IO ( stderr, Handle, IOMode(..), openFile, hClose, hPutStr, hPutStrLn
37+
, hGetContents, hSetEncoding, utf8 )
38+
import qualified Data.Map as Map
4739

4840
-- We need to force every file we open to be read in
4941
-- as UTF8
5042
alexReadFile :: FilePath -> IO String
51-
#if __GLASGOW_HASKELL__ >= 612
52-
alexReadFile file = do
53-
h <- alexOpenFile file ReadMode
54-
hGetContents h
55-
#else
56-
alexReadFile = readFile
57-
#endif
43+
alexReadFile file = hGetContents =<< alexOpenFile file ReadMode
5844

5945
-- We need to force every file we write to be written
6046
-- to as UTF8
6147
alexOpenFile :: FilePath -> IOMode -> IO Handle
62-
#if __GLASGOW_HASKELL__ >= 612
6348
alexOpenFile file mode = do
6449
h <- openFile file mode
6550
hSetEncoding h utf8
6651
return h
67-
#else
68-
alexOpenFile = openFile
69-
#endif
7052

7153
-- `main' decodes the command line arguments and calls `alex'.
7254

@@ -523,19 +505,3 @@ die s = hPutStr stderr s >> exitWith (ExitFailure 1)
523505

524506
dieAlex :: String -> IO a
525507
dieAlex s = getProgramName >>= \prog -> die (prog ++ ": " ++ s)
526-
527-
#if __GLASGOW_HASKELL__ < 610
528-
bracketOnError
529-
:: IO a -- ^ computation to run first (\"acquire resource\")
530-
-> (a -> IO b) -- ^ computation to run last (\"release resource\")
531-
-> (a -> IO c) -- ^ computation to run in-between
532-
-> IO c -- returns the value from the in-between computation
533-
bracketOnError before after thing =
534-
block (do
535-
a <- before
536-
r <- Exception.catch
537-
(unblock (thing a))
538-
(\e -> do { after a; throw e })
539-
return r
540-
)
541-
#endif

src/Map.hs

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/NFA.hs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,19 @@
1414
--
1515
-- ----------------------------------------------------------------------------}
1616

17-
{-# LANGUAGE CPP #-}
18-
1917
module NFA where
2018

19+
import Control.Monad ( forM_, zipWithM, zipWithM_, when, liftM, ap )
20+
import Data.Array ( Array, (!), array, listArray, assocs, bounds )
21+
import Data.Map ( Map )
22+
import qualified Data.Map as Map
23+
import qualified Data.List.NonEmpty as List1
24+
2125
import AbsSyn
2226
import CharSet
23-
import DFS ( t_close, out )
24-
import Map ( Map )
25-
import qualified Map
27+
import DFS ( t_close, out )
2628
import Util ( str, space )
2729

28-
#if __GLASGOW_HASKELL__ < 710
29-
import Control.Applicative ( Applicative(..) )
30-
#endif
31-
import Control.Monad ( forM_, zipWithM, zipWithM_, when, liftM, ap )
32-
import Data.Array ( Array, (!), array, listArray, assocs, bounds )
33-
import qualified Data.List.NonEmpty as List1
3430

3531
-- Each state of a nondeterministic automaton contains a list of `Accept'
3632
-- values, a list of epsilon transitions (an epsilon transition represents a

0 commit comments

Comments
 (0)