@@ -52,14 +52,6 @@ module Distribution.Simple.Compiler
5252 , coercePackageDBStack
5353 , readPackageDb
5454
55- -- * Support for optimisation levels
56- , OptimisationLevel (.. )
57- , flagToOptimisationLevel
58-
59- -- * Support for debug info levels
60- , DebugInfoLevel (.. )
61- , flagToDebugInfoLevel
62-
6355 -- * Support for language extensions
6456 , CompilerFlag
6557 , languageToFlags
@@ -96,22 +88,30 @@ module Distribution.Simple.Compiler
9688 , showProfDetailLevel
9789 ) where
9890
99- import Distribution.Compat.CharParsing
10091import Distribution.Compat.Prelude
101- import Distribution.Parsec
102- import Distribution.Pretty
92+ import Distribution.Parsec ( CabalParsing , Parsec ( .. ), parsecToken )
93+ import Distribution.Pretty ( prettyShow )
10394import Prelude ()
10495
10596import Distribution.Compiler
10697import Distribution.Package (PackageName )
107- import Distribution.Simple.Utils
98+ import Distribution.Simple.Utils ( lowercase , safeLast )
10899import Distribution.Types.UnitId (UnitId )
109100import Distribution.Utils.Path
110- import Distribution.Version
111-
112- import Language.Haskell.Extension
101+ ( CWD
102+ , FileOrDir (.. )
103+ , Pkg
104+ , PkgDB
105+ , SymbolicPath
106+ , getSymbolicPath
107+ , interpretSymbolicPath
108+ , makeSymbolicPath
109+ , symbolicPathRelative_maybe
110+ )
111+ import Distribution.Version (Version , mkVersion )
112+
113+ import Language.Haskell.Extension (Extension , Language (.. ))
113114
114- import Data.Bool (bool )
115115import qualified Data.Map as Map (lookup )
116116import System.Directory (canonicalizePath )
117117
@@ -304,95 +304,6 @@ coercePackageDBStack = map coercePackageDB
304304
305305-- ------------------------------------------------------------
306306
307- -- * Optimisation levels
308-
309- -- ------------------------------------------------------------
310-
311- -- | Some compilers support optimising. Some have different levels.
312- -- For compilers that do not the level is just capped to the level
313- -- they do support.
314- data OptimisationLevel
315- = NoOptimisation
316- | NormalOptimisation
317- | MaximumOptimisation
318- deriving (Bounded , Enum , Eq , Generic , Read , Show )
319-
320- instance Binary OptimisationLevel
321- instance NFData OptimisationLevel
322- instance Structured OptimisationLevel
323-
324- instance Parsec OptimisationLevel where
325- parsec = parsecOptimisationLevel
326-
327- parsecOptimisationLevel :: CabalParsing m => m OptimisationLevel
328- parsecOptimisationLevel = boolParser <|> intParser
329- where
330- boolParser = bool NoOptimisation NormalOptimisation <$> parsec
331- intParser = intToOptimisationLevel <$> integral
332-
333- flagToOptimisationLevel :: Maybe String -> OptimisationLevel
334- flagToOptimisationLevel Nothing = NormalOptimisation
335- flagToOptimisationLevel (Just s) = case reads s of
336- [(i, " " )] -> intToOptimisationLevel i
337- _ -> error $ " Can't parse optimisation level " ++ s
338-
339- intToOptimisationLevel :: Int -> OptimisationLevel
340- intToOptimisationLevel i
341- | i >= minLevel && i <= maxLevel = toEnum i
342- | otherwise =
343- error $
344- " Bad optimisation level: "
345- ++ show i
346- ++ " . Valid values are "
347- ++ show minLevel
348- ++ " .."
349- ++ show maxLevel
350- where
351- minLevel = fromEnum (minBound :: OptimisationLevel )
352- maxLevel = fromEnum (maxBound :: OptimisationLevel )
353-
354- -- ------------------------------------------------------------
355-
356- -- * Debug info levels
357-
358- -- ------------------------------------------------------------
359-
360- -- | Some compilers support emitting debug info. Some have different
361- -- levels. For compilers that do not the level is just capped to the
362- -- level they do support.
363- data DebugInfoLevel
364- = NoDebugInfo
365- | MinimalDebugInfo
366- | NormalDebugInfo
367- | MaximalDebugInfo
368- deriving (Bounded , Enum , Eq , Generic , Read , Show )
369-
370- instance Binary DebugInfoLevel
371- instance NFData DebugInfoLevel
372- instance Structured DebugInfoLevel
373-
374- instance Parsec DebugInfoLevel where
375- parsec = parsecDebugInfoLevel
376-
377- parsecDebugInfoLevel :: CabalParsing m => m DebugInfoLevel
378- parsecDebugInfoLevel = flagToDebugInfoLevel . pure <$> parsecToken
379-
380- flagToDebugInfoLevel :: Maybe String -> DebugInfoLevel
381- flagToDebugInfoLevel Nothing = NormalDebugInfo
382- flagToDebugInfoLevel (Just s) = case reads s of
383- [(i, " " )]
384- | i >= fromEnum (minBound :: DebugInfoLevel )
385- && i <= fromEnum (maxBound :: DebugInfoLevel ) ->
386- toEnum i
387- | otherwise ->
388- error $
389- " Bad debug info level: "
390- ++ show i
391- ++ " . Valid values are 0..3"
392- _ -> error $ " Can't parse debug info level " ++ s
393-
394- -- ------------------------------------------------------------
395-
396307-- * Languages and Extensions
397308
398309-- ------------------------------------------------------------
0 commit comments