summaryrefslogtreecommitdiff
path: root/compiler/utils/Util.lhs
Commit message (Collapse)AuthorAgeFilesLines
* Support code generation for unboxed-tuple function argumentsunboxed-tuple-arguments2Max Bolingbroke2012-05-151-1/+11
| | | | | | | | | | | This is done by a 'unarisation' pre-pass at the STG level which translates away all (live) binders binding something of unboxed tuple type. This has the following knock-on effects: * The subkind hierarchy is vastly simplified (no UbxTupleKind or ArgKind) * Various relaxed type checks in typechecker, 'foreign import prim' etc * All case binders may be live at the Core level
* Replace createDirectoryHierarchy with createDirectoryIfMissing TrueTakano Akio2012-02-271-14/+2
| | | | | | createDirectoryHierarchy consisted of an existence test followed by createDirectory, which failed if that directory was creted just after the test. createDirectoryifMissing does not have this problem.
* Switch to using the time package, rather than old-timeIan Lynagh2012-01-141-3/+21
|
* Add extra Num constraints since the Num superclass of Bits is removedBas van Dijk2012-01-141-3/+3
|
* Tabs -> SpacesDavid Terei2011-12-191-33/+28
|
* Fix bitrotted NCG_DEBUG code, and switch to using a Haskell conditionalIan Lynagh2011-11-051-1/+9
|
* Use -fwarn-tabs when validatingIan Lynagh2011-11-041-0/+7
| | | | | We only use it for "compiler" sources, i.e. not for libraries. Many modules have a -fno-warn-tabs kludge for now.
* Put the target platform in the settings fileIan Lynagh2011-10-191-1/+6
|
* Comments and functions renaming onlySimon Peyton Jones2011-09-231-9/+9
|
* Merge branch 'no-pred-ty'Max Bolingbroke2011-09-091-1/+10
|\ | | | | | | | | | | | | | | | | | | Conflicts: compiler/iface/BuildTyCl.lhs compiler/iface/MkIface.lhs compiler/iface/TcIface.lhs compiler/typecheck/TcTyClsDecls.lhs compiler/types/Class.lhs compiler/utils/Util.lhs
| * Implement -XConstraintKindMax Bolingbroke2011-09-061-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Basically as documented in http://hackage.haskell.org/trac/ghc/wiki/KindFact, this patch adds a new kind Constraint such that: Show :: * -> Constraint (?x::Int) :: Constraint (Int ~ a) :: Constraint And you can write *any* type with kind Constraint to the left of (=>): even if that type is a type synonym, type variable, indexed type or so on. The following (somewhat related) changes are also made: 1. We now box equality evidence. This is required because we want to give (Int ~ a) the *lifted* kind Constraint 2. For similar reasons, implicit parameters can now only be of a lifted kind. (?x::Int#) => ty is now ruled out 3. Implicit parameter constraints are now allowed in superclasses and instance contexts (this just falls out as OK with the new constraint solver) Internally the following major changes were made: 1. There is now no PredTy in the Type data type. Instead GHC checks the kind of a type to figure out if it is a predicate 2. There is now no AClass TyThing: we represent classes as TyThings just as a ATyCon (classes had TyCons anyway) 3. What used to be (~) is now pretty-printed as (~#). The box constructor EqBox :: (a ~# b) -> (a ~ b) 4. The type LCoercion is used internally in the constraint solver and type checker to represent coercions with free variables of type (a ~ b) rather than (a ~# b)
* | Implement associated type defaultsMax Bolingbroke2011-09-091-1/+10
|/ | | | | | | | | | | | | | | | | | | Basically, now you can write: class Cls a where type Typ a type Typ a = Just a And now if an instance does not specify an explicit associated type instance, one will be generated afresh based on that default. So for example this instance: instance Cls Int where Will be equivalent to this one: instance Cls Int where type Typ Int = Just Int
* Add CoreMonad.reinitializeGlobals so plugins can work around linker issuesMax Bolingbroke2011-07-291-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a plugin is loaded, it currently gets linked against a *newly loaded* copy of the GHC package. This would not be a problem, except that the new copy has its own mutable state that is not shared with that state that has already been initialized by the original GHC package. This leads to loaded plugins calling GHC code which pokes the static flags, and then dying with a panic because the static flags *it* sees are uninitialized. There are two possible solutions: 1. Export the symbols from the GHC executable from the GHC library and link against this existing copy rather than a new copy of the GHC library 2. Carefully ensure that the global state in the two copies of the GHC library matches I tried 1. and it *almost* works (and speeds up plugin load times!) except on Windows. On Windows the GHC library tends to export more than 65536 symbols (see #5292) which overflows the limit of what we can export from the EXE and causes breakage. (Note that if the GHC exeecutable was dynamically linked this wouldn't be a problem, because we could share the GHC library it links to.) We are going to try 2. instead. Unfortunately, this means that every plugin will have to say `reinitializeGlobals` before it does anything, but never mind. I've threaded the cr_globals through CoreM rather than giving them as an argument to the plugin function so that we can turn this function into (return ()) without breaking any plugins when we eventually get 1. working.
* Implement a findCycle function in Digraph,Simon Peyton Jones2011-07-221-1/+5
| | | | | | | | | | | | | | and use it to report module loops nicely This fixes Trac #5307. Now we get Module imports form a cycle: module `M8' (.\M8.hs) imports `M1' (M1.hs) which imports `M9' (.\M9.hs-boot) which imports `M8' (.\M8.hs) And the algorithm is linear time.
* Rename "extra-gcc-opts" to "settings", and start generalising itIan Lynagh2011-04-211-0/+14
|
* Force re-linking if the options have changed (#4451)Simon Marlow2011-04-081-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A common sequence of commands (at least for me) is this: $ ghc hello 1 of 1] Compiling Main ( hello.hs, hello.o ) Linking hello ... $ ./hello +RTS -s hello: Most RTS options are disabled. Link with -rtsopts to enable them. $ ghc hello -rtsopts $ grr, nothing happened. I could use -fforce-recomp, but if this was a large program I probably don't want to recompile it all again, so: $ rm hello removed `hello' $ ghc hello -rtsopts Linking hello ... $ ./hello +RTS -s ./hello +RTS -s Hello World! 51,264 bytes allocated in the heap 2,904 bytes copied during GC 43,808 bytes maximum residency (1 sample(s)) 17,632 bytes maximum slop etc. With this patch, GHC notices when the options have changed and forces a relink, so you don't need to rm the binary or use -fforce-recomp. This is done by adding the pertinent stuff to the binary in a special section called ".debug-ghc-link-info": $ readelf -p .debug-ghc-link-info ./hello String dump of section 'ghc-linker-opts': [ 0] (["-lHSbase-4.3.1.0","-lHSinteger-gmp-0.2.0.2","-lgmp","-lHSghc-prim-0.2.0.0","-lHSrts","-lm","-lrt","-ldl","-u","ghczmprim_GHCziTypes_Izh_static_info","-u","ghczmprim_GHCziTypes_Czh_static_info","-u","ghczmprim_GHCziTypes_Fzh_static_info","-u","ghczmprim_GHCziTypes_Dzh_static_info","-u","base_GHCziPtr_Ptr_static_info","-u","base_GHCziWord_Wzh_static_info","-u","base_GHCziInt_I8zh_static_info","-u","base_GHCziInt_I16zh_static_info","-u","base_GHCziInt_I32zh_static_info","-u","base_GHCziInt_I64zh_static_info","-u","base_GHCziWord_W8zh_static_info","-u","base_GHCziWord_W16zh_static_info","-u","base_GHCziWord_W32zh_static_info","-u","base_GHCziWord_W64zh_static_info","-u","base_GHCziStable_StablePtr_static_info","-u","ghczmprim_GHCziTypes_Izh_con_info","-u","ghczmprim_GHCziTypes_Czh_con_info","-u","ghczmprim_GHCziTypes_Fzh_con_info","-u","ghczmprim_GHCziTypes_Dzh_con_info","-u","base_GHCziPtr_Ptr_con_info","-u","base_GHCziPtr_FunPtr_con_info","-u","base_GHCziStable_StablePtr_con_info","-u","ghczmprim_GHCziTypes_False_closure","-u","ghczmprim_GHCziTypes_True_closure","-u","base_GHCziPack_unpackCString_closure","-u","base_GHCziIOziException_stackOverflow_closure","-u","base_GHCziIOziException_heapOverflow_closure","-u","base_ControlziExceptionziBase_nonTermination_closure","-u","base_GHCziIOziException_blockedIndefinitelyOnMVar_closure","-u","base_GHCziIOziException_blockedIndefinitelyOnSTM_closure","-u","base_ControlziExceptionziBase_nestedAtomically_closure","-u","base_GHCziWeak_runFinalizzerBatch_closure","-u","base_GHCziTopHandler_runIO_closure","-u","base_GHCziTopHandler_runNonIO_closure","-u","base_GHCziConcziIO_ensureIOManagerIsRunning_closure","-u","base_GHCziConcziSync_runSparks_closure","-u","base_GHCziConcziSignal_runHandlers_closure","-lHSffi"],Nothing,RtsOptsAll,False,[],[]) And GHC itself uses the readelf command to extract it when deciding whether to relink. The reason for the name ".debug-ghc-link-info" is that sections beginning with ".debug" are removed automatically by strip. This currently only works on Linux; Windows and OS X still have the old behaviour.
* Make fuzzy matching a little less eager for short identifierssimonpj@microsoft.com2011-01-071-3/+12
| | | | | For single-character identifiers we now don't make any suggestions See comments in Util.fuzzyLookup
* Add fuzzyLookup, a variant of fuzzyMatchsimonpj@microsoft.com2010-12-221-36/+73
| | | | Plus, I changed quite a bit of layout to make the lines shorter.
* Replace uses of the old catch function with the new oneIan Lynagh2010-12-181-4/+5
|
* Remove code that is dead now that we need >= 6.12 to buildIan Lynagh2010-12-151-8/+0
|
* looksLikeModuleName: allow apostrophe in module names (#4051)Simon Marlow2010-05-101-1/+1
|
* Spelling correction for LANGUAGE pragmasMax Bolingbroke2010-04-131-1/+96
|
* Add Data and Typeable instances to HsSynDavid Waern2010-03-301-0/+30
| | | | | The instances (and deriving declarations) have been taken from the ghc-syb package.
* Remove redundant importsimonpj@microsoft.com2010-02-081-1/+0
|
* locateOneObj: don't look for dynamic libs in static modeSimon Marlow2010-01-031-5/+5
| | | | | also replace picIsOn with isDynamicGhcLib, as __PIC__ is not the correct test for whether the GHC library is dynamically linked.
* Substantial improvements to coercion optimisationsimonpj@microsoft.com2010-01-041-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | The main purpose of this patch is to add a bunch of new rules to the coercion optimiser. They are documented in the (revised) Appendix of the System FC paper. Some code has moved about: - OptCoercion is now a separate module, mainly because it now uses tcMatchTy, which is defined in Unify, so OptCoercion must live higehr up in the hierarchy - Functions that manipulate Kinds has moved from Type.lhs to Coercion.lhs. Reason: the function typeKind now needs to call coercionKind. And in any case, a Kind is a flavour of Type, so it builds on top of Type; indeed Coercions and Kinds are both flavours of Type. This change required fiddling with a number of imports, hence the one-line changes to otherwise-unrelated modules - The representation of CoTyCons in TyCon has changed. Instead of an extensional representation (a kind checker) there is now an intensional representation (namely TyCon.CoTyConDesc). This was needed for one of the new coercion optimisations.
* Use the standard library versions of elem and notElemIan Lynagh2009-10-051-21/+12
| | | | rather than our own copies
* Make consIORef atomic.Thomas Schilling2009-08-221-4/+2
|
* generalise the type of "on"Simon Marlow2009-08-201-1/+1
|
* Make the dynamic linker thread-safe.Thomas Schilling2009-08-171-1/+10
| | | | | | | | | | | | The current implementation is rather pessimistic. The persistent linker state is now an MVar and all exported Linker functions are wrapped in modifyMVar calls. This is serves as a big lock around all linker functions. There might be a chance for more concurrency in a few places. E.g., extending the closure environment and loading packages might be independent in some cases. But for now it's better to be on the safe side.
* Remove maybePrefixMatch, using stripPrefix insteadIan Lynagh2009-07-091-10/+1
| | | | | We already require GHC 6.8 to build, and that included stripPrefix in Data.List.
* Trim unused imports detected by new unused-import codesimonpj@microsoft.com2009-07-061-2/+1
|
* Add the ability to derive instances of Functor, Foldable, Traversablesimonpj@microsoft.com2009-02-021-0/+5
| | | | | | | | | | | | This patch is a straightforward extension of the 'deriving' mechanism. The ability to derive classes Functor, Foldable, Traverable is controlled by a single flag -XDeriveFunctor. (Maybe that's a poor name.) Still to come: documentation Thanks to twanvl for developing the patch
* Improve warning for SpecConstrsimonpj@microsoft.com2008-09-151-0/+9
|
* use System.FilePath's isSearchPathSeparator instead of our ownSimon Marlow2008-08-181-12/+2
|
* Document UtilMax Bolingbroke2008-08-071-35/+38
|
* Follow changes in the base libraryIan Lynagh2008-07-311-19/+0
| | | | | TopHandler now uses the new extensible exceptions module, so we need to interact with it using the new types.
* Follow extensible exception changesIan Lynagh2008-07-301-2/+2
|
* Get building GHC itself with Cabal more-or-less workingIan Lynagh2008-07-161-2/+9
| | | | | Installing and bindist creation don't work, but they were already broken. Only tested validating with one setup.
* Remove code that isn't used now that we assume that GHC >= 6.4Ian Lynagh2008-06-201-10/+0
|
* Now that we require GHC >= 6.4.2, System.IO.Error is always availableIan Lynagh2008-06-201-1/+1
|
* Remove more ifdefferyIan Lynagh2008-06-141-1/+8
|
* Remove more ifdefferyIan Lynagh2008-06-141-1/+9
|
* Remove some ifdefferyIan Lynagh2008-06-141-1/+15
|
* Remove some CPPery with the help of a new value isWindowsHost in UtilIan Lynagh2008-06-121-2/+9
| | | | isWindowsHost is True iff mingw32_HOST_OS is defined.
* Rewrite zipLazy to be warning-free for GHC 6.4Ian Lynagh2008-05-131-1/+6
|
* Don't import FastString in HsVersions.hIan Lynagh2008-03-291-2/+0
| | | | Modules that need it import it themselves instead.
* Put debugIsOn in Util, rather than rely on it being CPPed inIan Lynagh2008-03-291-0/+16
|
* Add :run and tweak :mainIan Lynagh2008-01-191-36/+43
| | | | | | | You can now give :main a Haskell [String] as an argument, e.g. :main ["foo", "bar"] and :run is a variant that takes the name of the function to run. Also, :main now obeys the -main-is flag.
* lots of portability changes (#1405)Isaac Dupree2008-01-171-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | re-recording to avoid new conflicts was too hard, so I just put it all in one big patch :-( (besides, some of the changes depended on each other.) Here are what the component patches were: Fri Dec 28 11:02:55 EST 2007 Isaac Dupree <id@isaac.cedarswampstudios.org> * document BreakArray better Fri Dec 28 11:39:22 EST 2007 Isaac Dupree <id@isaac.cedarswampstudios.org> * properly ifdef BreakArray for GHCI Fri Jan 4 13:50:41 EST 2008 Isaac Dupree <id@isaac.cedarswampstudios.org> * change ifs on __GLASGOW_HASKELL__ to account for... (#1405) for it not being defined. I assume it being undefined implies a compiler with relatively modern libraries but without most unportable glasgow extensions. Fri Jan 4 14:21:21 EST 2008 Isaac Dupree <id@isaac.cedarswampstudios.org> * MyEither-->EitherString to allow Haskell98 instance Fri Jan 4 16:13:29 EST 2008 Isaac Dupree <id@isaac.cedarswampstudios.org> * re-portabilize Pretty, and corresponding changes Fri Jan 4 17:19:55 EST 2008 Isaac Dupree <id@isaac.cedarswampstudios.org> * Augment FastTypes to be much more complete Fri Jan 4 20:14:19 EST 2008 Isaac Dupree <id@isaac.cedarswampstudios.org> * use FastFunctions, cleanup FastString slightly Fri Jan 4 21:00:22 EST 2008 Isaac Dupree <id@isaac.cedarswampstudios.org> * Massive de-"#", mostly Int# --> FastInt (#1405) Fri Jan 4 21:02:49 EST 2008 Isaac Dupree <id@isaac.cedarswampstudios.org> * miscellaneous unnecessary-extension-removal Sat Jan 5 19:30:13 EST 2008 Isaac Dupree <id@isaac.cedarswampstudios.org> * add FastFunctions