Reputation: 1151
I see in this answer and this one that "everything will break horribly" and Stack won't let me replace base, but it will let me replace bytestring. What's the problem with this? Is there a way to do this safely without recompiling GHC? I'm debugging a problem with the base libraries and it'd be very convenient.
N.B. when I say I want to replace base
I mean with a modified version of base
from the same GHC version. I'm debugging the library, not testing a program against different GHC releases.
Upvotes: 2
Views: 118
Reputation: 153172
Most libraries are collections of Haskell modules containing Haskell code. The meaning of those libraries is determined by the code in the modules.
The base
package, though, is a bit different. Many of the functions and data types it offers are not implemented in standard Haskell; their meaning is not given by the code contained in the package, but by the compiler itself. If you look at the source of the base
package (and the other boot libraries), you will see many operations whose complete definition is simply undefined
. Special code in the compiler's runtime system implements these operations and exposes them.
For example, if the compiler didn't offer seq
as a primitive operation, there would be no way to implement seq
after-the-fact: no Haskell term that you can write down will have the same type and semantics as seq
unless it uses seq
(or one of the Haskell extensions defined in terms of seq
). Likewise many of the pointer operations, ST
operations, concurrency primitives, and so forth are implemented in the compiler themselves.
Not only are these operations typically unimplementable, they also are typically very strongly tied to the compiler's internal data structures, which change from one release to the next. So even if you managed to convince GHC to use the base
package from a different (version of the) compiler, the most likely outcome would simply be corrupted internal data structures with unpredictable (and potentially disastrous) results -- race conditions, trashing memory, space leaks, segfaults, that kind of thing.
If you need several versions of base, just install several versions of GHC. It's been carefully architected so that multiple versions can peacefully coexist on a single machine. (And in particular installing multiple versions definitely does not require recompiling GHC or even compiling GHC a first time, which seems to be your main concern.)
Upvotes: 5