2 % (c) The AQUA Project, Glasgow University, 1996-98
4 \section[CmdLineOpts]{Things to do with command-line options}
18 opt_AllowOverlappingInstances,
19 opt_AllowUndecidableInstances,
20 opt_AutoSccsOnAllToplevs,
21 opt_AutoSccsOnExportedToplevs,
22 opt_AutoSccsOnIndividualCafs,
32 opt_D_dump_occur_anal,
37 opt_D_dump_simpl_iterations,
42 opt_D_dump_worker_wrapper,
46 opt_D_show_rn_imports,
47 opt_D_simplifier_stats,
49 opt_D_verbose_core2core,
50 opt_D_verbose_stg2stg,
58 opt_EnsureSplittableC,
60 opt_UnboxStrictFields,
65 opt_IgnoreIfacePragmas,
67 opt_IrrefutableTuples,
68 opt_LiberateCaseThreshold,
69 opt_MaxContextReductionDepth,
70 opt_MultiParamClasses,
72 opt_NoImplicitPrelude,
76 opt_OmitInterfacePragmas,
83 opt_ProduceExportCStubs,
84 opt_ProduceExportHStubs,
90 opt_StgDoLetNoEscapes,
93 opt_InterfaceUnfoldThreshold,
95 opt_UnfoldingCreationThreshold,
96 opt_UnfoldingConDiscount,
97 opt_UnfoldingUseThreshold,
98 opt_UnfoldingKeenessFactor,
102 opt_WarnNameShadowing,
103 opt_WarnUnusedMatches,
105 opt_WarnUnusedImports,
106 opt_WarnIncompletePatterns,
107 opt_WarnOverlappingPatterns,
108 opt_WarnSimplePatterns,
109 opt_WarnTypeDefaults,
110 opt_WarnMissingMethods,
111 opt_WarnDuplicateExports,
114 opt_PruneTyDecls, opt_PruneInstDecls,
118 #include "HsVersions.h"
120 import Array ( array, (//) )
123 import Constants -- Default values for some flags
125 import Maybes ( assocMaybe, firstJust, maybeToBool )
126 import Panic ( panic, panic# )
128 #if __GLASGOW_HASKELL__ < 301
129 import ArrBase ( Array(..) )
131 import PrelArr ( Array(..) )
135 A command-line {\em switch} is (generally) either on or off; e.g., the
136 ``verbose'' (-v) switch is either on or off. (The \tr{-G<group>}
137 switch is an exception; it's set to a string, or nothing.)
139 A list of {\em ToDo}s is things to be done in a particular part of
140 processing. A (fictitious) example for the Core-to-Core simplifier
141 might be: run the simplifier, then run the strictness analyser, then
142 run the simplifier again (three ``todos'').
144 There are three ``to-do processing centers'' at the moment. In the
145 main loop (\tr{main/Main.lhs}), in the Core-to-Core processing loop
146 (\tr{simplCore/SimplCore.lhs), and in the STG-to-STG processing loop
147 (\tr{simplStg/SimplStg.lhs}).
149 %************************************************************************
151 \subsection{Datatypes associated with command-line options}
153 %************************************************************************
157 = SwBool Bool -- on/off
158 | SwString FAST_STRING -- nothing or a String
159 | SwInt Int -- nothing or an Int
163 data CoreToDo -- These are diff core-to-core passes,
164 -- which may be invoked in any order,
165 -- as many times as you like.
167 = CoreDoSimplify -- The core-to-core simplifier.
168 (SimplifierSwitch -> SwitchResult)
169 -- Each run of the simplifier can take a different
170 -- set of simplifier-specific flags.
171 | CoreDoCalcInlinings1
172 | CoreDoCalcInlinings2
179 | CoreDoWorkerWrapper
181 | CoreDoFoldrBuildWorkerWrapper
182 | CoreDoFoldrBuildWWAnal
189 | StgDoUpdateAnalysis
191 | StgDoMassageForProfiling -- should be (next to) last
192 -- There's also setStgVarInfo, but its absolute "lastness"
193 -- is so critical that it is hardwired in (no flag).
198 data SimplifierSwitch
200 | SimplFloatLetsExposingWHNF
201 | SimplOkToFloatPrimOps
202 | SimplAlwaysFloatLetsFromLets
206 | SimplMayDeleteConjurableIds
207 | SimplPedanticBottoms -- see Simplifier for an explanation
208 | SimplDoArityExpand -- expand arity of bindings
209 | SimplDoFoldrBuild -- This is the per-simplification flag;
210 -- see also FoldrBuildOn, used elsewhere
212 | SimplDoInlineFoldrBuild
213 -- inline foldr/build (*after* f/b rule is used)
216 | SimplDoLambdaEtaExpansion
218 | EssentialUnfoldingsOnly -- never mind the thresholds, only
219 -- do unfoldings that *must* be done
220 -- (to saturate constructors and primitives)
222 | MaxSimplifierIterations Int
224 | SimplNoLetFromCase -- used when turning off floating entirely
225 | SimplNoLetFromApp -- (for experimentation only) WDP 95/10
226 | SimplNoLetFromStrictLet
232 %************************************************************************
234 \subsection{Classifying command-line options}
236 %************************************************************************
239 lookUp :: FAST_STRING -> Bool
240 lookup_int :: String -> Maybe Int
241 lookup_def_int :: String -> Int -> Int
242 lookup_def_float :: String -> Float -> Float
243 lookup_str :: String -> Maybe String
245 lookUp sw = maybeToBool (assoc_opts sw)
247 lookup_str sw = firstJust (map (startsWith sw) unpacked_opts)
249 lookup_int sw = case (lookup_str sw) of
251 Just xx -> Just (read xx)
253 lookup_def_int sw def = case (lookup_str sw) of
254 Nothing -> def -- Use default
257 lookup_def_float sw def = case (lookup_str sw) of
258 Nothing -> def -- Use default
261 assoc_opts = assocMaybe [ (a, True) | a <- argv ]
262 unpacked_opts = map _UNPK_ argv
265 Putting the compiler options into temporary at-files
266 may turn out to be necessary later on if we turn hsc into
267 a pure Win32 application where I think there's a command-line
268 length limit of 255. unpacked_opts understands the @ option.
270 assoc_opts = assocMaybe [ (_PK_ a, True) | a <- unpacked_opts ]
272 unpacked_opts :: [String]
278 expandAts ('@':fname) = words (unsafePerformIO (readFile fname))
284 opt_AllStrict = lookUp SLIT("-fall-strict")
285 opt_AllowOverlappingInstances = lookUp SLIT("-fallow-overlapping-instances")
286 opt_AllowUndecidableInstances = lookUp SLIT("-fallow-undecidable-instances")
287 opt_AutoSccsOnAllToplevs = lookUp SLIT("-fauto-sccs-on-all-toplevs")
288 opt_AutoSccsOnExportedToplevs = lookUp SLIT("-fauto-sccs-on-exported-toplevs")
289 opt_AutoSccsOnIndividualCafs = lookUp SLIT("-fauto-sccs-on-individual-cafs")
290 opt_AutoSccsOnDicts = lookUp SLIT("-fauto-sccs-on-dicts")
292 It's a bit unfortunate to have to re-introduce this chap, but on Win32
293 platforms we do need a way of distinguishing between the case when we're
294 compiling a static version of the Prelude and one that's going to be
295 put into a DLL. Why? Because the compiler's wired in modules need to
296 be attributed as either coming from a DLL or not.
298 opt_CompilingPrelude = lookUp SLIT("-fcompiling-prelude")
299 opt_D_dump_absC = lookUp SLIT("-ddump-absC")
300 opt_D_dump_asm = lookUp SLIT("-ddump-asm")
301 opt_D_dump_deriv = lookUp SLIT("-ddump-deriv")
302 opt_D_dump_ds = lookUp SLIT("-ddump-ds")
303 opt_D_dump_flatC = lookUp SLIT("-ddump-flatC")
304 opt_D_dump_inlinings = lookUp SLIT("-ddump-inlinings")
305 opt_D_dump_foreign = lookUp SLIT("-ddump-foreign-stubs")
306 opt_D_dump_occur_anal = lookUp SLIT("-ddump-occur-anal")
307 opt_D_dump_rdr = lookUp SLIT("-ddump-rdr")
308 opt_D_dump_realC = lookUp SLIT("-ddump-realC")
309 opt_D_dump_rn = lookUp SLIT("-ddump-rn")
310 opt_D_dump_simpl = lookUp SLIT("-ddump-simpl")
311 opt_D_dump_simpl_iterations = lookUp SLIT("-ddump-simpl-iterations")
312 opt_D_dump_spec = lookUp SLIT("-ddump-spec")
313 opt_D_dump_stg = lookUp SLIT("-ddump-stg")
314 opt_D_dump_stranal = lookUp SLIT("-ddump-stranal")
315 opt_D_dump_worker_wrapper = lookUp SLIT("-ddump-workwrap")
316 opt_D_dump_cpranal = lookUp SLIT("-ddump-cpranalyse")
317 opt_D_dump_tc = lookUp SLIT("-ddump-tc")
318 opt_D_show_passes = lookUp SLIT("-dshow-passes")
319 opt_D_show_rn_trace = lookUp SLIT("-dshow-rn-trace")
320 opt_D_show_rn_imports = lookUp SLIT("-dshow-rn-imports")
321 opt_D_simplifier_stats = lookUp SLIT("-dsimplifier-stats")
322 opt_D_source_stats = lookUp SLIT("-dsource-stats")
323 opt_D_verbose_core2core = lookUp SLIT("-dverbose-simpl")
324 opt_D_verbose_stg2stg = lookUp SLIT("-dverbose-stg")
325 opt_DictsStrict = lookUp SLIT("-fdicts-strict")
326 opt_DoCoreLinting = lookUp SLIT("-dcore-lint")
327 opt_DoStgLinting = lookUp SLIT("-dstg-lint")
328 opt_DoEtaReduction = lookUp SLIT("-fdo-eta-reduction")
329 opt_DoSemiTagging = lookUp SLIT("-fsemi-tagging")
330 opt_DoTickyProfiling = lookUp SLIT("-fticky-ticky")
331 opt_EmitCExternDecls = lookUp SLIT("-femit-extern-decls")
332 opt_EnsureSplittableC = lookUp SLIT("-fglobalise-toplev-names")
333 opt_FoldrBuildOn = lookUp SLIT("-ffoldr-build-on")
334 opt_UnboxStrictFields = lookUp SLIT("-funbox-strict-fields")
335 opt_GranMacros = lookUp SLIT("-fgransim")
336 opt_GlasgowExts = lookUp SLIT("-fglasgow-exts")
337 opt_HiMap = lookup_str "-himap=" -- file saying where to look for .hi files
338 opt_HiVersion = lookup_def_int "-fhi-version=" 0 -- what version we're compiling.
339 opt_IgnoreIfacePragmas = lookUp SLIT("-fignore-interface-pragmas")
340 opt_IgnoreAsserts = lookUp SLIT("-fignore-asserts")
341 opt_IrrefutableTuples = lookUp SLIT("-firrefutable-tuples")
342 opt_MaxContextReductionDepth = lookup_def_int "-fcontext-stack" mAX_CONTEXT_REDUCTION_DEPTH
343 opt_MultiParamClasses = opt_GlasgowExts
344 opt_NoHiCheck = lookUp SLIT("-fno-hi-version-check")
345 opt_NoImplicitPrelude = lookUp SLIT("-fno-implicit-prelude")
346 opt_NoPreInlining = lookUp SLIT("-fno-pre-inlining")
347 opt_NumbersStrict = lookUp SLIT("-fnumbers-strict")
348 opt_OmitBlackHoling = lookUp SLIT("-dno-black-holing")
349 opt_OmitInterfacePragmas = lookUp SLIT("-fomit-interface-pragmas")
350 opt_PprStyle_NoPrags = lookUp SLIT("-dppr-noprags")
351 opt_PprStyle_Debug = lookUp SLIT("-dppr-debug")
352 opt_PprUserLength = lookup_def_int "-dppr-user-length" 5 --ToDo: give this a name
353 opt_ProduceC = lookup_str "-C="
354 opt_ProduceS = lookup_str "-S="
355 opt_ProduceExportCStubs = lookup_str "-F="
356 opt_ProduceExportHStubs = lookup_str "-FH="
357 opt_ProduceHi = lookup_str "-hifile=" -- the one to produce this time
358 opt_ReportCompile = lookUp SLIT("-freport-compile")
359 opt_SccProfilingOn = lookUp SLIT("-fscc-profiling")
360 opt_SourceUnchanged = lookUp SLIT("-fsource-unchanged")
361 opt_StgDoLetNoEscapes = lookUp SLIT("-flet-no-escape")
362 opt_Parallel = lookUp SLIT("-fparallel")
363 opt_Static = lookUp SLIT("-static")
364 opt_SccGroup = lookup_str "-G="
365 opt_Verbose = lookUp SLIT("-v")
367 opt_UnfoldCasms = lookUp SLIT("-funfold-casms-in-hi-file")
368 opt_InterfaceUnfoldThreshold = lookup_def_int "-funfolding-interface-threshold" iNTERFACE_UNFOLD_THRESHOLD
369 opt_UnfoldingCreationThreshold = lookup_def_int "-funfolding-creation-threshold" uNFOLDING_CREATION_THRESHOLD
370 opt_UnfoldingUseThreshold = lookup_def_int "-funfolding-use-threshold" uNFOLDING_USE_THRESHOLD
371 opt_UnfoldingConDiscount = lookup_def_int "-funfolding-con-discount" uNFOLDING_CON_DISCOUNT_WEIGHT
373 opt_LiberateCaseThreshold = lookup_def_int "-fliberate-case-threshold" lIBERATE_CASE_THRESHOLD
374 opt_UnfoldingKeenessFactor = lookup_def_float "-funfolding-keeness-factor" uNFOLDING_KEENESS_FACTOR
375 opt_WarnNameShadowing = lookUp SLIT("-fwarn-name-shadowing")
376 opt_WarnHiShadows = lookUp SLIT("-fwarn-hi-shadowing")
377 opt_WarnIncompletePatterns = lookUp SLIT("-fwarn-incomplete-patterns")
378 opt_WarnOverlappingPatterns = lookUp SLIT("-fwarn-overlapping-patterns")
379 opt_WarnSimplePatterns = lookUp SLIT("-fwarn-simple-patterns")
380 opt_WarnTypeDefaults = lookUp SLIT("-fwarn-type-defaults")
381 opt_WarnUnusedMatches = lookUp SLIT("-fwarn-unused-matches")
382 opt_WarnUnusedBinds = lookUp SLIT("-fwarn-unused-binds")
383 opt_WarnUnusedImports = lookUp SLIT("-fwarn-unused-imports")
384 opt_WarnMissingMethods = lookUp SLIT("-fwarn-missing-methods")
385 opt_WarnDuplicateExports = lookUp SLIT("-fwarn-duplicate-exports")
386 opt_WarnMissingSigs = lookUp SLIT("-fwarn-missing-signatures")
387 opt_PruneTyDecls = not (lookUp SLIT("-fno-prune-tydecls"))
388 opt_PruneInstDecls = not (lookUp SLIT("-fno-prune-instdecls"))
389 opt_D_show_rn_stats = lookUp SLIT("-dshow-rn-stats")
391 -- opt_UnfoldingOverrideThreshold = lookup_int "-funfolding-override-threshold"
395 classifyOpts :: ([CoreToDo], -- Core-to-Core processing spec
396 [StgToDo]) -- STG-to-STG processing spec
398 classifyOpts = sep argv [] [] -- accumulators...
400 sep :: [FAST_STRING] -- cmd-line opts (input)
401 -> [CoreToDo] -> [StgToDo] -- to_do accumulators
402 -> ([CoreToDo], [StgToDo]) -- result
404 sep [] core_td stg_td -- all done!
405 = (reverse core_td, reverse stg_td)
407 # define CORE_TD(to_do) sep opts (to_do:core_td) stg_td
408 # define STG_TD(to_do) sep opts core_td (to_do:stg_td)
410 sep (opt1:opts) core_td stg_td
411 = case (_UNPK_ opt1) of -- the non-"just match a string" options are at the end...
412 ',' : _ -> sep opts core_td stg_td -- it is for the parser
414 "-fsimplify" -> -- gather up SimplifierSwitches specially...
415 simpl_sep opts defaultSimplSwitches core_td stg_td
417 "-fcalc-inlinings1"-> CORE_TD(CoreDoCalcInlinings1)
418 "-fcalc-inlinings2"-> CORE_TD(CoreDoCalcInlinings2)
419 "-ffloat-inwards" -> CORE_TD(CoreDoFloatInwards)
420 "-ffull-laziness" -> CORE_TD(CoreDoFullLaziness)
421 "-fliberate-case" -> CORE_TD(CoreLiberateCase)
422 "-fprint-core" -> CORE_TD(CoreDoPrintCore)
423 "-fstatic-args" -> CORE_TD(CoreDoStaticArgs)
424 "-fstrictness" -> CORE_TD(CoreDoStrictness)
425 "-fworker-wrapper" -> CORE_TD(CoreDoWorkerWrapper)
426 "-fspecialise" -> CORE_TD(CoreDoSpecialising)
427 "-ffoldr-build-worker-wrapper" -> CORE_TD(CoreDoFoldrBuildWorkerWrapper)
428 "-ffoldr-build-ww-anal" -> CORE_TD(CoreDoFoldrBuildWWAnal)
429 "-fcpr-analyse" -> CORE_TD(CoreDoCPResult)
431 "-fstg-static-args" -> STG_TD(StgDoStaticArgs)
432 "-fupdate-analysis" -> STG_TD(StgDoUpdateAnalysis)
433 "-dstg-stats" -> STG_TD(D_stg_stats)
434 "-flambda-lift" -> STG_TD(StgDoLambdaLift)
435 "-fmassage-stg-for-profiling" -> STG_TD(StgDoMassageForProfiling)
437 _ -> -- NB: the driver is really supposed to handle bad options
438 sep opts core_td stg_td
442 simpl_sep :: [FAST_STRING] -- cmd-line opts (input)
443 -> [SimplifierSwitch] -- simplifier-switch accumulator
444 -> [CoreToDo] -> [StgToDo] -- to_do accumulators
445 -> ([CoreToDo], [StgToDo]) -- result
447 -- "simpl_sep" tailcalls "sep" once it's seen one set
448 -- of SimplifierSwitches for a CoreDoSimplify.
451 simpl_sep input@[] simpl_sw core_td stg_td
452 = panic "simpl_sep []"
455 -- The SimplifierSwitches should be delimited by "[" and "]".
457 simpl_sep (opt1:opts) simpl_sw core_td stg_td
458 = case (_UNPK_ opt1) of
459 "[" -> simpl_sep opts simpl_sw core_td stg_td
461 this_simpl = CoreDoSimplify (isAmongSimpl simpl_sw)
463 sep opts (this_simpl : core_td) stg_td
465 # define SIMPL_SW(sw) simpl_sep opts (sw:simpl_sw) core_td stg_td
467 -- the non-"just match a string" options are at the end...
468 "-fcode-duplication-ok" -> SIMPL_SW(SimplOkToDupCode)
469 "-ffloat-lets-exposing-whnf" -> SIMPL_SW(SimplFloatLetsExposingWHNF)
470 "-ffloat-primops-ok" -> SIMPL_SW(SimplOkToFloatPrimOps)
471 "-falways-float-lets-from-lets" -> SIMPL_SW(SimplAlwaysFloatLetsFromLets)
472 "-fdo-case-elim" -> SIMPL_SW(SimplDoCaseElim)
473 "-fdo-lambda-eta-expansion" -> SIMPL_SW(SimplDoLambdaEtaExpansion)
474 "-fdo-foldr-build" -> SIMPL_SW(SimplDoFoldrBuild)
475 "-fdo-arity-expand" -> SIMPL_SW(SimplDoArityExpand)
476 "-fdo-inline-foldr-build" -> SIMPL_SW(SimplDoInlineFoldrBuild)
477 "-fcase-of-case" -> SIMPL_SW(SimplCaseOfCase)
478 "-fcase-merge" -> SIMPL_SW(SimplCaseMerge)
479 "-flet-to-case" -> SIMPL_SW(SimplLetToCase)
480 "-fpedantic-bottoms" -> SIMPL_SW(SimplPedanticBottoms)
481 "-fmay-delete-conjurable-ids" -> SIMPL_SW(SimplMayDeleteConjurableIds)
482 "-fessential-unfoldings-only" -> SIMPL_SW(EssentialUnfoldingsOnly)
483 "-fignore-inline-pragma" -> SIMPL_SW(IgnoreINLINEPragma)
484 "-fno-let-from-case" -> SIMPL_SW(SimplNoLetFromCase)
485 "-fno-let-from-app" -> SIMPL_SW(SimplNoLetFromApp)
486 "-fno-let-from-strict-let" -> SIMPL_SW(SimplNoLetFromStrictLet)
487 "-fclone-binds" -> SIMPL_SW(SimplPleaseClone)
489 o | starts_with_msi -> SIMPL_SW(MaxSimplifierIterations (read after_msi))
491 maybe_msi = startsWith "-fmax-simplifier-iterations" o
492 starts_with_msi = maybeToBool maybe_msi
493 (Just after_msi) = maybe_msi
495 _ -> -- NB: the driver is really supposed to handle bad options
496 simpl_sep opts simpl_sw core_td stg_td
499 %************************************************************************
501 \subsection{Switch ordering}
503 %************************************************************************
505 In spite of the @Produce*@ and @SccGroup@ constructors, these things
506 behave just like enumeration types.
509 instance Eq SimplifierSwitch where
510 a == b = tagOf_SimplSwitch a _EQ_ tagOf_SimplSwitch b
512 instance Ord SimplifierSwitch where
513 a < b = tagOf_SimplSwitch a _LT_ tagOf_SimplSwitch b
514 a <= b = tagOf_SimplSwitch a _LE_ tagOf_SimplSwitch b
516 tagOf_SimplSwitch SimplOkToDupCode =(ILIT(0) :: FAST_INT)
517 tagOf_SimplSwitch SimplFloatLetsExposingWHNF = ILIT(1)
518 tagOf_SimplSwitch SimplOkToFloatPrimOps = ILIT(2)
519 tagOf_SimplSwitch SimplAlwaysFloatLetsFromLets = ILIT(3)
520 tagOf_SimplSwitch SimplDoCaseElim = ILIT(4)
521 tagOf_SimplSwitch SimplCaseOfCase = ILIT(6)
522 tagOf_SimplSwitch SimplLetToCase = ILIT(7)
523 tagOf_SimplSwitch SimplMayDeleteConjurableIds = ILIT(9)
524 tagOf_SimplSwitch SimplPedanticBottoms = ILIT(10)
525 tagOf_SimplSwitch SimplDoArityExpand = ILIT(11)
526 tagOf_SimplSwitch SimplDoFoldrBuild = ILIT(12)
527 tagOf_SimplSwitch SimplDoInlineFoldrBuild = ILIT(14)
528 tagOf_SimplSwitch IgnoreINLINEPragma = ILIT(15)
529 tagOf_SimplSwitch SimplDoLambdaEtaExpansion = ILIT(16)
530 tagOf_SimplSwitch EssentialUnfoldingsOnly = ILIT(19)
531 tagOf_SimplSwitch (MaxSimplifierIterations _) = ILIT(21)
532 tagOf_SimplSwitch SimplNoLetFromCase = ILIT(27)
533 tagOf_SimplSwitch SimplNoLetFromApp = ILIT(28)
534 tagOf_SimplSwitch SimplNoLetFromStrictLet = ILIT(29)
535 tagOf_SimplSwitch SimplCaseMerge = ILIT(31)
536 tagOf_SimplSwitch SimplPleaseClone = ILIT(32)
538 -- If you add anything here, be sure to change lAST_SIMPL_SWITCH_TAG, too!
540 tagOf_SimplSwitch _ = panic# "tagOf_SimplSwitch"
542 lAST_SIMPL_SWITCH_TAG = IBOX(tagOf_SimplSwitch SimplPleaseClone)
545 %************************************************************************
547 \subsection{Switch lookup}
549 %************************************************************************
552 isAmongSimpl :: [SimplifierSwitch] -> SimplifierSwitch -> SwitchResult
554 isAmongSimpl on_switches -- Switches mentioned later occur *earlier*
555 -- in the list; defaults right at the end.
557 tidied_on_switches = foldl rm_dups [] on_switches
558 -- The fold*l* ensures that we keep the latest switches;
559 -- ie the ones that occur earliest in the list.
561 sw_tbl :: Array Int SwitchResult
563 sw_tbl = (array (0, lAST_SIMPL_SWITCH_TAG) -- bounds...
567 all_undefined = [ (i, SwBool False) | i <- [0 .. lAST_SIMPL_SWITCH_TAG ] ]
569 defined_elems = map mk_assoc_elem tidied_on_switches
571 -- (avoid some unboxing, bounds checking, and other horrible things:)
572 case sw_tbl of { Array bounds_who_needs_'em stuff ->
574 case (indexArray# stuff (tagOf_SimplSwitch switch)) of
575 #if __GLASGOW_HASKELL__ < 400
582 mk_assoc_elem k@(MaxSimplifierIterations lvl) = (IBOX(tagOf_SimplSwitch k), SwInt lvl)
584 mk_assoc_elem k = (IBOX(tagOf_SimplSwitch k), SwBool True) -- I'm here, Mom!
586 -- cannot have duplicates if we are going to use the array thing
587 rm_dups switches_so_far switch
588 = if switch `is_elem` switches_so_far
590 else switch : switches_so_far
592 sw `is_elem` [] = False
593 sw `is_elem` (s:ss) = (tagOf_SimplSwitch sw) _EQ_ (tagOf_SimplSwitch s)
597 Default settings for simplifier switches
600 defaultSimplSwitches = [MaxSimplifierIterations 1
604 %************************************************************************
606 \subsection{Misc functions for command-line options}
608 %************************************************************************
612 switchIsOn :: (switch -> SwitchResult) -> switch -> Bool
614 switchIsOn lookup_fn switch
615 = case (lookup_fn switch) of
616 SwBool False -> False
619 intSwitchSet :: (switch -> SwitchResult)
623 intSwitchSet lookup_fn switch
624 = case (lookup_fn (switch (panic "intSwitchSet"))) of
625 SwInt int -> Just int
630 startsWith, endsWith :: String -> String -> Maybe String
632 startsWith [] str = Just str
633 startsWith (c:cs) (s:ss)
634 = if c /= s then Nothing else startsWith cs ss
635 startsWith _ [] = Nothing
638 = case (startsWith (reverse cs) (reverse ss)) of
640 Just rs -> Just (reverse rs)