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